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:
Any idea why this isn't working?
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?