Results 1 to 5 of 5
  1. #1
    notrino is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Feb 2016
    Location
    Izmir,Turkey
    Posts
    60

    Double Criteria for Open Form

    Hello,

    You know, we can open the form with criteria via this code;
    (Buton click event);



    Code:
    DoCmd.OpenForm "FormName", acNormal, , "[ID1]=" & Me.ID1
    But, if we have 2 pcs. criteria, how can I open that form? For example ID1 for main form, ID2 for subform, so I want to call at the same time ID1 and ID2. How can I change above code? Thanks

    Note:https://www.access-programmers.co.uk...d.php?t=302065

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    Try:

    DoCmd.OpenForm "Tablo2", acNormal, , "[ID1]=" & Me.ID1 & " AND [ID2]=" & Me.alt1!ID2
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    How is the data in the subform linked to the main form?
    Normally that controls what is displayed in the subform, and therefore you only need to open the relevant main ID ?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #4
    notrino is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Feb 2016
    Location
    Izmir,Turkey
    Posts
    60
    Hello June7,

    Your solution giving error like this;
    Click image for larger version. 

Name:	Error.JPG 
Views:	12 
Size:	120.3 KB 
ID:	35964

    Hello Minty,
    For example ID1 can be include different ID3 values. Like;
    ID1=1 --> ID3=1
    ID1=1 --> ID3=2
    ID1=1 --> ID3 =3
    And
    ID3 can be include a lot of different records. For example, I want to see "ID1=1 and ID3=2" records via one click button. I need to double criteria.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    @Minty, I looked at the db from other thread. Appears OP wants to open a third form that has a RecordSource which includes both tables. But now that I look at it again, you are correct. The fields ID1 and ID2 are PK/FK so they have the same values. Don't need ID2 in the criteria.

    Well, where did you use the code you originally posted? The database doesn't have any VBA code.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 10-29-2014, 03:25 AM
  2. Double click on listbox to open up form
    By EthanMoist in forum Forms
    Replies: 14
    Last Post: 05-21-2013, 02:10 PM
  3. Replies: 2
    Last Post: 02-13-2013, 04:14 PM
  4. On Double Click Open Form with two criteria
    By AndreasPanayiotou in forum Programming
    Replies: 3
    Last Post: 09-10-2012, 08:47 AM
  5. Replies: 10
    Last Post: 02-20-2012, 11:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums