Results 1 to 2 of 2
  1. #1
    swenger is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2016
    Posts
    151

    Using a Public Variable in criteria of a Query

    I have a Public Variable called Prd which I confirmed has a value since I created a button which simply on event is msgbox {variable} and when I click on the button the correct value shows.

    I have a query which I would like to use the Variable as the criteria, however when i type the variable Prd in the criteria for that column it encloses it in [Prd] but when I run the query I still get a pop up to enter a value for [Prd]

    What is the fix for this?



    Thanks
    Sam

  2. #2
    swenger is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2016
    Posts
    151
    So I found on Microsoft site that you can't use a variable in a criteria of a query so I followed their solution to create a Function which calls this variable and use the Function in the criteria.

    This worked.

    Thanks

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

Similar Threads

  1. Displaying a Public Variable on a form
    By swenger in forum Programming
    Replies: 1
    Last Post: 06-23-2016, 01:56 PM
  2. Replies: 5
    Last Post: 04-27-2015, 02:40 PM
  3. Replies: 6
    Last Post: 04-07-2015, 03:41 PM
  4. How to use global/public variable
    By mrbabji in forum Programming
    Replies: 7
    Last Post: 05-18-2013, 10:08 PM
  5. Replies: 1
    Last Post: 03-28-2013, 07:54 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