0

I am opening a form and trying to fill it with data using a query that contains a global variable. This causes an alert box to pop up, prompting me to fill it with a value because the syntax is wrong somehow obviously. The table is staff and currentStaffMember is the global variable. This code is in a query.

Here is the code:

SELECT *
FROM Staff
WHERE EmployeeID = currentStaffMember;

https://imagebin.ca/v/3Z7LERXZNvnk (image showing record source)

https://imagebin.ca/v/3Z7Lhn9BnJzl (image showing query)

1
  • Can you add the code creating the query? Commented Sep 3, 2017 at 13:04

1 Answer 1

1

You can't use global variables set in VBA in normal queries.

You can, however, use TempVars for exactly that purpose.

Set a TempVar: TempVars!currentStaffMember = "John Doe"

Use a TempVar in a query:

SELECT *
FROM Staff
WHERE EmployeeID = Tempvars!currentStaffMember;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.