If you use [cod e] (but without the space I included) and its [/cod e] counterpart, your code will be easier to read... 9Makes it fixed pitch)
Code:
Private Sub Combo1_GotFocus()
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Path & ";" & _
"Persist Security Info=Fals"
cn.Open
rs.Open "SELECT * " & _
"FROM tblMaterial " & _
"WHERE MaterialID = '" & Str(Combo1.Text) & "' ;", _
cn, adOpenDynamic, adLockOptimistic
With orders
.qty1 = rs.Fields(1)
.desc1 = rs.Fields(2)
.price1 = rs.Fields(3)
End With
rs.Close
I think the problem is in your SQL. IDs (like MaterialID) are usually numeric. You encapsulated the results of Str(Combo1.Text) in quotes (shown just below in bold, underlined red):
Code:
rs.Open "SELECT * " & _
Code:
"FROM tblMaterial " & _
"WHERE MaterialID = [u]'</u>" & Str(Combo1.Text) & "[u]'</u> ;", _
cn, adOpenDynamic, adLockOptimistic
That compares the quoted literal string with a number, a type mismatch.