Run-time error 3075 Syntax error (Missing operator)

abzalali

Registered User.
Local time
Today, 09:57
Joined
Dec 12, 2012
Messages
118
Dear Exper,
Getting error with this code, Please help me.
Code:
    Dim db As DAO.Database, sSQL As String
    Set db = CurrentDb()
             sSQL = "UPDATE [Dive Crew]" _
            & "Set [Dive Crew].InitInvConf = -1" _
            & "WHERE [Dive Crew].InvoiceNumber = [Forms]![frmInvoice]![cboInv];"
    db.Execute sSQL, dbSeeChanges

Thanks
Mir
 
Try This:-

Code:
    Dim db As DAO.Database, sSQL As String
    Set db = CurrentDb()
             sSQL = "UPDATE [Dive Crew]" _
            & " Set [Dive Crew].InitInvConf = -1" _
            & " WHERE [Dive Crew].InvoiceNumber = [Forms]![frmInvoice]![cboInv]"
    db.Execute sSQL, dbSeeChanges
 
Code:
sSQL = "UPDATE [Dive Crew[COLOR="blue"]] "[/COLOR] _
            & "Set [Dive Crew].InitInvConf = -[COLOR="Blue"]1 " [/COLOR]_
            & "WHERE [Dive Crew].InvoiceNumber = [Forms]![frmInvoice]![cboInv];"
... spaces
 
Yes.. VB and seeing as it looks like it's for MSSQL server, should we get rid of the ; as well?
 
@ vbaInet
Run time error 3061
Too few parameters. Expected 1
 
Dear Sir,
Why this is not work? Please help me!!!!!!!!!!!:banghead:

Thanks
Mir
 
Dim db As DAO.Database, sSQL As String Set db = CurrentDb() sSQL = "UPDATE [Dive Crew]" _ & " Set [Dive Crew].InitInvConf = -1" _ & " WHERE [Dive Crew].InvoiceNumber = '" & [Forms]![frmInvoice]![cboInv] & "'" db.Execute sSQL, dbSeeChanges

' Single quotes assume that InvoiceNumber is Text field. Remove the ' if it is not.
 
Thank you Sir (Royce)
Now it works nicely. Thanks you sooooooooooo much.
 
If you want to execute an SQL statement with parameters you have a couple of options:

1. Concatenate it like Royce showed (although s/he has put it all on one line so I'm guessing s/he's logged in from his/her phone)
2. Create a query with the parameter, use the querydef object to get the parameter value and execute it using the querydef
3. Use DoCmd.RunSQL to execute it with the parameter enclosed
Code:
sSQL = "UPDATE [Dive Crew] " _
            & "Set [Dive Crew].InitInvConf = -1 " _
            & "WHERE [Dive Crew].InvoiceNumber = [Forms]![frmInvoice]![cboInv];"
DoCmd.RunSQL sSQL

@Uncle T: Hmmm... I'm not sure if it's SQL Server.
 

Users who are viewing this thread

Back
Top Bottom