Results 1 to 3 of 3
  1. #1
    liam is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2015
    Posts
    2

    Referring to a field on multiple forms in query criteria

    In my database I have multiple forms which all have a field with the same name. What I want to do is to have a query where the criteria is based on the shared field but from whichever of the forms is open. I have tried:

    [Forms]![Form1]![Field] OR [Forms]![Form2]![Field] ... - running the query just gives a prompt for all the forms are not open

    I tried searching for an answer and some posts suggested subforms, the problem with this is that I have no idea how to reference the subform in the query criteria when the subform is present on several forms, I have tried using Me.[Subform].form![Field], [Forms]![Parent].[Subform].form.[Field], and other combinations of . and ! (not entirely sure which I should use) but neither of these work.

    Is there a way to reference a subform in a query criteria without specifying the exact form it is present on because I really don't want to make lots of different queries that are almost identical?

    Any guidance on this would be greatly appreciated!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    The query will only work on 1 form.
    if you have 2 forms ,then you need 2 queries.

    if you want to reference a sub form, use the BUILDER, to pick the object.
    it will always get it right.

  3. #3
    liam is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2015
    Posts
    2
    Quote Originally Posted by ranman256 View Post
    The query will only work on 1 form.
    if you have 2 forms ,then you need 2 queries.

    if you want to reference a sub form, use the BUILDER, to pick the object.
    it will always get it right.
    I can use the builder to get the criteria to reference the subform but only for a specific form. The subform I want to reference is used on several forms and I want to reference the subform independent of whichever parent form is open with a single criteria, is that not possible?

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

Similar Threads

  1. Replies: 2
    Last Post: 04-02-2015, 12:45 PM
  2. Referring to a cell with a date in query criteria
    By Historypaul in forum Queries
    Replies: 5
    Last Post: 06-08-2014, 03:54 PM
  3. Replies: 7
    Last Post: 07-02-2013, 12:02 PM
  4. Multiple 'AfterUpdates' referring to single Function
    By karmacable in forum Programming
    Replies: 3
    Last Post: 09-15-2011, 06:19 PM
  5. Query multiple field & criteria
    By fua in forum Access
    Replies: 2
    Last Post: 11-04-2009, 08:22 PM

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