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

ACCESS - SQL query through VBA & textbox

Status
Not open for further replies.

szynszyl

MIS
Dec 30, 2007
11
IT
Hi,
I've created in VBA a USerform named (form1) in which I've one textbox1 and one clickbutton.

After complete textbox1 and push clickbutton I would like to run this query based on fact that the variable in textbox1 is passed to SQL string , currently it doesn't work.

RS.Open "SELECT * FROM [VENDOR DATA] WHERE [Buyer]=Forms!Form1!textbox1.value"

Please take note that form I've create is not the automatic form in Access available but I've created in VBA development area.

Do you have suggestion ?
 
Hi,

Forum705.

Why a Textbox and not a Combobox of valid Buyers?

Again, you'll get better results in an Access forum.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
probably construct your query as a text string, bringing in the value from the textbox or combobox before you execute the query:
"SELECT * FROM [VENDOR DATA] WHERE [Buyer]= '" & Forms!Form1!textbox1.value & "'"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top