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

Populating datagrid with results of SQL query not working. :(

Status
Not open for further replies.

Raydr

IS-IT--Management
Mar 19, 2002
20
US
Hello...I am BRAND NEW to db programming (about 3 hours into it) and basically I'm writing an inventory program to keep track of cable boxes, modems, etc in our warehouse.


I have a datagrid that upon load, has a list of every box in the warehouse in the first column, and in the 2nd, it has the tech number of the guy who has it.

Right above it, I have a combo box that has a list of the different types of boxes, such as Digital, Analog, Modem, Music. (these values are loaded from the database).

I want the user to be able to choose the type of boxes that are listed in the datagrid via the combobox.

I've already got the SQL statement set up, and I'm retrieving the data into a recordset variable, but I would like for it all to be automatically put into the datagrid.

Here's the code I have so far:

Code:
Private Sub cboEQTypes_Click()
Dim dbInventory As New ADODB.Connection
Dim rsInventory As New ADODB.Recordset
Dim test As String
Dim SQL As String

'open my database
dbInventory.Open "dsn=Inventory"

'build SQL statement
SQL = "SELECT EqNum, Tech From Equipment Where (EqType = " & Me.cboEQTypes.ItemData(Me.cboEQTypes.ListIndex) & ")"

'put the data I want into rsInventory
Set rsInventory = dbInventory.Execute(SQL)

'according to what I've read, the
'following line SHOULD be doing
'what I"m trying to accomplish, but it's NOT:
Me.gridInventory.Datasource = rsInventory	
M.gridInventory.Refresh

dbInventory.Close

End Sub

Any idea why this isn't working?
 
P.S.: I KNOW that the data is being retrieved into the recordset variable, I've verified it by msgboxing some of the data and it's there. It just won't go into the datagrid.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top