1

This error is appearing in following line of the vb code

 rs.Open "select * From Reservation where [table_number]=tablenumber.text and booking_date=bookingdate.Text", cn, adOpenStatic, adLockPessimistic
Bugs
  • 4,491
  • 9
  • 32
  • 41
dapinder
  • 33
  • 1
  • 1
  • 4

3 Answers3

10

It's a problem with your SQL query. The reason for the message is that the SQL parser can't identify a token in your SQL query and interprets it as a parameter for which you need to provide a value.

So, you either mistyped some of your field or table names, or you created your SQL the wrong way. I suppose the latter and it should read

 rs.Open "select * From Reservation where [table_number] = " & tablenumber.text & " and booking_date=" & bookingdate.Text, cn, adOpenStatic, adLockPessimistic

because tablenumber and bookingdate are very likely form controls.

The above query won't work out of the box as you need to use the correct data types for the SQL query which I cannot infer based on your sparse information.

MicSim
  • 26,265
  • 16
  • 90
  • 133
1

If you are INSERTing values in TABLE - dont miss enclosing it in single quotes, like ' " & text1.text & " '

example:

INSERT into [TABLE NAME]([Purchase Order Status]) values(' " & text1.text & " ')
parakmiakos
  • 2,994
  • 9
  • 29
  • 43
0

I would suggest adding () around the selection criteria:

rs.Open "select * From Reservation where ( [table_number]=tablenumber.text and booking_date=bookingdate.Text )" 
Bugs
  • 4,491
  • 9
  • 32
  • 41
Dale
  • 147
  • 7