Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Struggling with Where Clause in OpenForm

Status
Not open for further replies.

david6633

Programmer
Jul 28, 2003
39
GB
I am having a problem with the WHERE clause when trying to open a form.

If I use

DoCmd.OpenForm "Appointments", , , "LeaderId = 34"

then it opens the form with the correct details but if I try to use a variable, as below

DoCmd.OpenForm "Appointments", , , "LeaderId = " & Leader

then I get the record but I do not get the name that is linked to the LeaderId record (the variable does contain valid data).

I know that this must be something to do with syntax but I cannot work out where I am going wrong - can anyone spot where I am going wrong?

David
Remember: You only know what you know
and - you don't know what you don't know!
 
Hi david6633,

What is Leader? Is it a variable or a field? If it is a field you need to have it inside the quotes ..

Code:
[blue]DoCmd.OpenForm "Appointments", , , "LeaderId = [Leader]" [/blue]

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
Sorry - I did not have a problem at alll with the WHERE clause, the problem I had was with the data that I was using [colorface]

David
Remember: You only know what you know
and - you don't know what you don't know!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top