Using A "SELECT" SQL command in VB from within access?

Spacemonkeynz

New member
Local time
Yesterday, 22:35
Joined
Jun 3, 2008
Messages
1
What i'm trying to do is when a user clicks A command button, I want some VB code to retrieve data from the database using an SQL command. The data can come back either as a recordset, or as a single value.

But i'm not to sure where to start.

Access has DoCmd.RunSQL(), which can be used for 'INSERT' SQL commands, but it can't be used for 'SELECT' commands.


Also


Basically I would like something like this

Dim rs As Recordset

rs = [some command here](SELECT * FROM table)

is something like this possible?


Thanks
 
Space,

Just use the Search Facility here and look for "Recordset", you'll find plenty of
examples.

Wayne
 
something like this maybe:

Dim sSql As String
Dim MyRecordSet As Recordset

sSql = "Select ItemName from ItemData where ItemName = 'whatEva'"
Set MyRecordSet = CurrentDb.OpenRecordset(sSql)
 

Users who are viewing this thread

Back
Top Bottom