Passing a variable on a form to a pass-through query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I created a form where the user will type in a ID number. I want to pass
this ID number into my pass through query to bring back records only
associated with this ID. I tried the following:

ID = Forms!Form1!txtID.value

or

ID = '" & Forms!Form1!txtID.value & "'

I can't get anything to work. Is it even possible to do this?

Thanks
 
tacos said:
I created a form where the user will type in a ID number. I want to
pass this ID number into my pass through query to bring back records
only associated with this ID. I tried the following:

ID = Forms!Form1!txtID.value

or

ID = '" & Forms!Form1!txtID.value & "'

I can't get anything to work. Is it even possible to do this?

Thanks

You have to re-write the SQL for the passthrough query and have the new SQL
include the value (not a reference).

CurrentDB.QueryDefs("QueryName").sql = "Some New SQL " &
Forms!Form1!txtID.value & " Some More SQL"
 
Thanks for the help. I had know idea about querydef, but my queries work
great now. Thanks again.
 
Back
Top