Results 1 to 3 of 3
  1. #1
    lccrews is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Location
    Los Angeles
    Posts
    194

    Question on the 'or' property of a query


    I'd like to get a little more clarity on how to use the 'or' property of the query. I have a query set up to return results based on input from a form text box. That same query is also being used on a different form. I'd like to list that 2nd form in the 'or' function, but every time I run the query a parameter (the unopened form) is being displayed. Is it possible to get the query to work with both forms without showing the parameter pop up for the closed form? ...Or do I have to create 2 identical queries?


    Example: I have a query to return all records related to "CO#" from Forms!myform1!Mycontrol. I'd like to have Forms!myform2!Mycontrol in the 'or' function. So when I open myform1 and run the query, I do not get a popup asking for input from myform2

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I don't use dynamic parameterized queries. I prefer VBA to filter the form (macro can do this as well).

    So code behind myform2 to open myform1.

    DoCmd.OpenForm "myform1", , , "[fieldname]=" & Mycontrol

    This allows more flexibility in using the query.
    Last edited by June7; 12-05-2017 at 06:53 PM.
    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
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Is it possible to get the query to work with both forms without showing the parameter pop up for the closed form? ...Or do I have to create 2 identical queries?
    What I think you're asking for is doable but requires coding. You cannot expect a query to simply default to one of the OR criteria statements simply because it cannot resolve the other one. It's like saying, If I say to you "Do A if balloon is blue or do B if ball is black" and I don't show you the ball, what are you going to say? Show me the ball...

    You might be able to call a function that checks to see which form is open and then returns the value from the correct control on the opened form.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 1
    Last Post: 05-17-2017, 01:21 AM
  2. Replies: 1
    Last Post: 03-05-2016, 05:22 AM
  3. Replies: 1
    Last Post: 01-09-2015, 12:09 PM
  4. Replies: 11
    Last Post: 11-26-2010, 10:53 PM
  5. Query Question
    By blewis in forum Queries
    Replies: 0
    Last Post: 04-16-2009, 01:37 PM

Tags for this Thread

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