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.
Code:
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
Last edited by firoz.raj; December 27th, 2009 at 04:15 AM.
Do the same thing we keep saying in all the other threads. If you paste that into Access, it will tell you the error. (I suspect ID is a reserved word, that you have to change)
Otherwise, what's in the textbox? If it's a number, then things should work
Could it be that the Supplier_ID is an AUTO_ALLOCATED field which means you cannot allocate a number to it (ever) ???
It is Auto Allocated by the database when you first add a record
Only you know the answer as we cannot see your table definitions
The last few requests for help you have posted are about this exact problem. (You never tell us if this answer solves your problem, but you stop asking when given this answer)
It will go a long way to help everyone help you, if you put RESOLVED along side your posts where relevant
Please FIROZ - if what I am telling you is correct, follow these instructions
1) Put a link to this thread on your desktop
2) Next time you get a syntax error which has any field name with _ID associated with it, click the link
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.