Link to home
Start Free TrialLog in
Avatar of marku24
marku24Flag for United States of America

asked on

Need correct syntax for SQL statement in VBA

I am having trouble executing the below code in Access VBA.  I assume my SQL statement syntax is off.  Possibly with Date or Currency?

Dim strInvoiceID As String
Dim curInvoiceAmt As Currency
Dim datInvoiceDate As Date
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim strUser As String


strInvoiceID = Form_frmDashboard.txtLstBoxInvID.Value
curInvoiceAmt = Form_frmDashboard.txtInvRcvdAmt.Value
datInvoiceDate = Format(Form_frmDashboard.txtInvRcvdDate, "yyyy\/mm\/d")



Set db = CurrentDb()

strSQL = "Select * from [tblReceivableManagament]"

Set rs = db.OpenRecordset(strSQL)

    If rs.RecordCount > 0 Then
            'clear existing log in that may not have cleared out
           
        Else
    End If

strUser = "'" & fncUserID & "'"
strInvoiceID = "'" & strInvoiceID & "'"




            strSQL = "INSERT INTO tblReceivableManagement (Invoice#, InvoicePaidDate, InvoicePaidAmount, UserID)VALUES(" & strInvoiceID & ", #" & datInvoiceDate & "#,curInvoiceAmt, " & strUser & ")"
           

            db.Execute (strSQL)
SOLUTION
Avatar of lludden
lludden
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of marku24

ASKER

nice job, thank you.  That special character screwed me up.