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

SQL statement in VBA

Status
Not open for further replies.

bill1one

Programmer
Sep 29, 2004
93
US
I'm trying to create a form that would include a listbox and a query would run depending on the result in the listbox. It would be similar to a filter by form, except I'd be providing the values in a listbox. I assume I need to use VBA to accomplish this, but I don't know how to include an SQL statement into my VBA code.

Here is the SQL statement I have:

SELECT [tblResolution].[Number], [tblResolution].[Type], [tblResolution].[Description], [tblResolution].[Date]
FROM tblResolution
WHERE (((tblResolution.Type)=[]));

Basically I want the listbox to fill in the WHERE part.

Does anyone know of any good resources on how to incorporate SQL statements into VBA so that I can learn how to do this?

Thanks.
 
I guess you're playing with access.
And what do you want to do with the SQL statement ?
It should be the RecordSource of the form ?
If it's the case, you may try this as RecordSource:
SQL = "SELECT [Number], [Type], [Description], [Date] FROM tblResolution" _
& " WHERE [Type]='" & Me![name of listbox] & "'"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top