Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax error (missing operator) 1

Status
Not open for further replies.

jpl458

Technical User
Sep 30, 2009
337
US
I have the following line of code that generates "Syntax error (missing operator) in query expression 'where dbo_ZSSP_Coupons.ID='46". On the rsdbo_Open StrCoupon

The code is in the LostFocus of a text box named ID_Number, into which I have entered 46 then tabbed out of the box. Here is the code.

'----------Set up SQL Query----------------------------------------
Dim StrCoupon As Variant
StrCoupon = "SELECT dbo_ZSSP_Coupons.Id_Number,"
StrCoupon = StrCoupon + " dbo_ZSSP_Coupons.CAddress,"
StrCoupon = StrCoupon + " dbo_ZSSP_Coupons.CDateTime,"
StrCoupon = StrCoupon + " where dbo_ZSSP_Coupons.ID_Number='" & Me.ID_Number & "'"

'----------Set Connection To Database-----------------------------------
Dim cnndbo As ADODB.Connection
Set cnndbo = CurrentProject.Connection
Dim rsdbo As New ADODB.Recordset
rsdbo.ActiveConnection = cnndbo
rsdbo.CursorType = adOpenDynamic
'---------Send Query to Server-----------------------------------------
rsdbo_Open StrCoupon

This code was copied and from another application that works, but I have changes lables. I have compared the two and they match. So I have no clue.


Thanks in advance

jpl
 


Where is the FROM caluse?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Silly mistake in copying.

Thanks

jpl
 

Do yourself a favor and use:

'----------Set up SQL Query----------------------------------------
Dim StrCoupon As Variant
StrCoupon = "SELECT dbo_ZSSP_Coupons.Id_Number,"
StrCoupon = StrCoupon + " dbo_ZSSP_Coupons.CAddress,"
StrCoupon = StrCoupon + " dbo_ZSSP_Coupons.CDateTime,"
StrCoupon = StrCoupon + " where dbo_ZSSP_Coupons.ID_Number='" & Me.ID_Number & "'"[red]
Debug.Print StrCoupon[/red]
'----------Set Connection To Database-----------------------------------

to see your SQL in Immediate Window.

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top