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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is running SQL Queries with information entered into a form possible?

Status
Not open for further replies.

MisterMan

Technical User
Jun 4, 2002
87
US
Like the subject line says. I have been trying to figure this off an on for two days now... Like, for example, someone has a form with a tect entry box, and then a search button that would allow for a Query to be run, using the information entered into the text box as part of the Query.

Any suggestions? Everytime I try to code this I think I make dumb mistakes, so I thought I would ask.
J
 
The amount of information you have given is limited but to use the vale of a text box within a SQL statement is

set Recordset=Currentdb.openrecordset("SELECT DogType FROM Dogs WHERE DogType = '" & Forms!FormName!TextBoxName & "'"

The single quotes around the double quotes are for text strings, omit these if the data type is a number.

Hope this helps
 
Hey Lenny, sorry for being vague.

It appears to start to work, but then I get a "Too few parameters. Expected 1" error message.
Any suggestions?
 
You are receiving this error because there is no value coming out of the text box ie null

does the text box hold a text string or number because the syntax for each is different?

text '" & Forms!FormName!TextBoxName & "'
number " & Forms!FormName!TextBoxName & "'

without more specific info, it is hard to be of more help
 
Actually, I figured it out. I had put the textbox name syntax in wrong. Thank you for helping the dumb guy :)
J
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top