marku24
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.txtLstBo xInvID.Val ue
curInvoiceAmt = Form_frmDashboard.txtInvRc vdAmt.Valu e
datInvoiceDate = Format(Form_frmDashboard.t xtInvRcvdD ate, "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)
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.txtLstBo
curInvoiceAmt = Form_frmDashboard.txtInvRc
datInvoiceDate = Format(Form_frmDashboard.t
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER