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

select query in vb...

Status
Not open for further replies.

marlun

Programmer
Feb 7, 2003
70
0
0
SE
Hi! I have a form where i do a search in a table. I want to do the selection from the table depending on what i write in the textfield with vb. Something like

strSQL = "SELECT (*) FROM table WHERE id = SEARCHFIELD ON THE FORM"

And then I want to able to see the result in a listbox.

As you can see am i not that familiar with the sql-language

Appreciate any help
 
Hi!

[tt]strSQL = "SELECT * FROM
WHERE id = " & Me!SomeNumeric.Value[/tt]

Should it be text, use text delimiters:

[tt]strSQL = "SELECT * FROM
WHERE id = '" & Me!SomeText.Value & "'"[/tt]

After that, assign it to the lists rowsource:

[tt]me!MyList.RowSource=strSQL[/tt]

If "table" is the name of the table, surround it with [brackets], cause it's a reserved word.

Roy-Vidar
 
You will also need to requery the listbox after setting the RowSource...
me!MyList.requery
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top