UPDATE!
Hello again,
I have found the solution to my own problem! I found that all I had to do was insert this teeny weeny bit of code in the following places:
Private Sub cmdUpdateDropDowns_Click()
strSQL = "Select Distinct [Item] From [data$] Order by [Item]"
closeRS
OpenDB
cmbProducts.Clear
rs.Open strSQL, cnn, adOpenKeyset, adLockOptimistic
If rs.RecordCount > 0 Then
Do While Not rs.EOF
cmbProducts.AddItem rs.Fields(0)
rs.MoveNext
Loop
Else
MsgBox "I was not able to find any unique Products.", vbCritical + vbOKOnly
Exit Sub
End If
'----------------------------
strSQL = "Select Distinct [ID#] From [data$] Order by [ID#]"
closeRS
OpenDB
cmbID.Clear
rs.Open strSQL, cnn, adOpenKeyset, adLockOptimistic
If rs.RecordCount > 0 Then
Do While Not rs.EOF
cmbID.AddItem rs.Fields(0)
rs.MoveNext
Loop
Else
MsgBox "I was not able to find any unique Region(s).", vbCritical + vbOKOnly
Exit Sub
End If
End
End Sub
Private Sub cmdShowData_Click()
Dim intSQL As Integer
'populate data
strSQL = "SELECT * FROM [data$] WHERE "
If cmbProducts.Text <> "" Then
strSQL = strSQL & " [Item]='" & cmbProducts.Text & "'"
End If
If cmbID.Text <> "" Then
If cmbProducts.Text <> "" Then
strSQL = strSQL & " AND [ID#]='" & cmbID.Text & "'"
Else
strSQL = strSQL & " [ID#]='" & cmbID.Text & "'"
End If
End If
If cmbProducts.Text <> "" Or cmbID.Text <> "" Then
'now extract data
closeRS
OpenDB
rs.Open strSQL, cnn, adOpenKeyset, adLockOptimistic
If rs.RecordCount > 0 Then
Sheets("Search").Visible = True
Sheets("Search").Select
Range("dataSet").Select
Range(Selection, Selection.End(xlDown)).ClearContents
'Now putting the data on the sheet
ActiveCell.CopyFromRecordset rs
Else
MsgBox "I was not able to find any matching records.", vbExclamation + vbOKOnly
Exit Sub
End If
End If
End
End Sub
If anyone doesn't get it let me know!
Have a great day,
Sleepyshy
Bookmarks