query based off a textbox value

G

Guest

Looking for a hand if possible. New to access and sql. I want one
textbox(txt2) to query a table based off the value in another textbox(txt1).
I've tried to create an SQL query as the control source for txt2. Not sure
if my syntax is off or
if this is the best way to do this. When the form loads, #NAME is what
appears in txt2. Here's the synatx. tbl_equipmentlist is part of the form's
record source. An example or correction would be appreicated.

SELECT tbl_equipmentlist.Equipment_ID FROM tbl_equipmentlist WHERE
(((tbl_equipmentlist.Equipment_ID)=FORMS!frmProject!txt1));

Thanks
 
K

Ken Snell [MVP]

You cannot use an SQL query statement as the control source of a textbox.
You could use a DLookup function to do the same thing, though:

=DLookup("Equipment_ID", "tbl_equipmentlist", "Equipment_ID=" & [txt1])

Not sure why you're looking up the equipment ID value when it already exists
in the other textbox, though.....
 
G

Guest

Ken,

Thanks for clarifiying the dlookup statment. I had a type-o in my quesiton.
The value that is being looked up is different from what it in txt1. I'll
try this
out. Thanks!!

Dave.

Ken Snell said:
You cannot use an SQL query statement as the control source of a textbox.
You could use a DLookup function to do the same thing, though:

=DLookup("Equipment_ID", "tbl_equipmentlist", "Equipment_ID=" & [txt1])

Not sure why you're looking up the equipment ID value when it already exists
in the other textbox, though.....


--

Ken Snell
<MS ACCESS MVP>

Dave said:
Looking for a hand if possible. New to access and sql. I want one
textbox(txt2) to query a table based off the value in another textbox(txt1).
I've tried to create an SQL query as the control source for txt2. Not sure
if my syntax is off or
if this is the best way to do this. When the form loads, #NAME is what
appears in txt2. Here's the synatx. tbl_equipmentlist is part of the form's
record source. An example or correction would be appreicated.

SELECT tbl_equipmentlist.Equipment_ID FROM tbl_equipmentlist WHERE
(((tbl_equipmentlist.Equipment_ID)=FORMS!frmProject!txt1));

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top