can anybody tell me why i got syntax error(missing operator) in query expression'ID='; here is the code what i have written.any help would be greatly appreciated.

Private Sub Command2_Click()
If CheckInput = True Then
    Dim success As Boolean
    Set con = New ADODB.Connection
    success = OpenConnection(con)
 If success = False Then
      MsgBox ("Cannot Open Connection")
      Exit Sub
End If
Set rs = New ADODB.Recordset
rs.Open "select * from supplierS where ID=" & Text1.Text, con, adOpenDynamic, adLockOptimistic
 If rs.BOF And rs.EOF Then rs.AddNew
 ' rs.Fields("Supplier_id") = Text1.Text
   rs.Fields("Supplier_name") = Text2.Text
   rs.Fields("contact_person") = Text3.Text
   rs.Fields("contact_no") = Text4.Text
   rs.Fields("office_address") = Text6.Text
   rs.Fields("emails") = Text7.Text
   rs.Fields("website") = Text8.Text
   rs.Fields("Fax_no") = Text5.Text
   rs.Fields("item_type") = Combo1.Text
   rs.Update
   MsgBox ("data saved")
   rs.Close
 Else
   Exit Sub
End If
con.Close
Set con = Nothing
End Sub

try to add " & Text1.Text & " instead of " & Text1.Text

"ID" Varible is Numberic then try this:

rs.Open "select * from supplierS where ID=#" & Text1.Text & "#", con, adOpenDynamic, adLockOptimistic

"ID" Variable is Text then Try this:

A) Unique Record
rs.Open "select * from supplierS where ID LIKE '" & Text1.Text & "'", con, adOpenDynamic, adLockOptimistic

B) More than one Record
rs.Open "select * from supplierS where ID LIKE '" & Text1.Text & "*'", con, adOpenDynamic, adLockOptimistic

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.