Results 1 to 2 of 2
  1. #1
    Bkper087 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    May 2014
    Posts
    81

    Dlookup criteria with OR function

    In an effort to simplify the number of queries, tables, and forums I have in my database, I would like to see if I can use the same form for a task that would change depending on which form was open.

    The current code is below.

    =(DLookUp("[NumberofUnits]","[tblExpense]","[ProjectExpenseTrackingID]=" & [Forms]![frmExpense_Actual]![ProjectExpenseTrackingID])-(DSum("[NumberofUnits]","[tblSplitExpense]")))

    To keep things simple, what I am looking to do is something like this:
    DLookUp("[ExampleField]","[Table]","[Criteria]=" & [Forms]![frmExample]![ExampleField] OR[Forms]![frmExample2]![ExampleField2]

    The criteria would check to see which form is open. Obviously this isn't working. Any suggestions?

  2. #2
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Using the same form in multiple ways is good design practice. Consider using the OpenArgs property of the opened form to decide on what to do; probably basing that decision in a Select Case block in the form's OnLoad or OnOpen event, depending on what you need to do.

    https://msdn.microsoft.com/en-us/lib.../ff820845.aspx
    Last edited by Micron; 03-27-2017 at 07:24 PM. Reason: added link

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

Similar Threads

  1. DLOOKUP Function for Multiple Criteria.
    By cap.zadi in forum Forms
    Replies: 9
    Last Post: 05-31-2017, 05:01 PM
  2. Replies: 5
    Last Post: 03-11-2016, 01:03 PM
  3. Replies: 15
    Last Post: 07-09-2015, 01:39 AM
  4. Replies: 4
    Last Post: 06-30-2014, 02:53 PM
  5. Dlookup Function
    By MarkHenderson in forum Queries
    Replies: 1
    Last Post: 11-19-2012, 03:00 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