SheilaAlighieri
Technical User
Hi People!
I have a small problem with my VB code. It has to copy records to another table. It works fine as long as the AmountEuro field contains decimals(for example 2000). But when I try to copy one with decimals (for example 200,05) I get a syntax error. What am I doing wrong?
Thanks!
---------
Private Sub Button__Add__Click()
On Error GoTo Err_Button__Add__Click
Dim rst As ADODB.Recordset
Dim myDte As Date
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenKeyset
rst.LockType = adLockPessimistic
myDte = DateAdd("yyyy", 1, Forms![Data Entry]!InvoiceDte)
If (MsgBox("The system will now copy this invoice to the budget of next year.", vbInformation + vbOKCancel, "Advertising & Promotion Commitment System" = vbOK) Then
rst.Open "SELECT * " _
& "FROM Budget " _
& "WHERE ([Account Code] = " & AccountCode & " " _
& "AND (BudgetDate = #" & myDte & "#) " _
& "AND (Budget = " & AmountEuro & " " _
& "AND (Description = '" & Description & "') ;"
-----------
I have a small problem with my VB code. It has to copy records to another table. It works fine as long as the AmountEuro field contains decimals(for example 2000). But when I try to copy one with decimals (for example 200,05) I get a syntax error. What am I doing wrong?
Thanks!
---------
Private Sub Button__Add__Click()
On Error GoTo Err_Button__Add__Click
Dim rst As ADODB.Recordset
Dim myDte As Date
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenKeyset
rst.LockType = adLockPessimistic
myDte = DateAdd("yyyy", 1, Forms![Data Entry]!InvoiceDte)
If (MsgBox("The system will now copy this invoice to the budget of next year.", vbInformation + vbOKCancel, "Advertising & Promotion Commitment System" = vbOK) Then
rst.Open "SELECT * " _
& "FROM Budget " _
& "WHERE ([Account Code] = " & AccountCode & " " _
& "AND (BudgetDate = #" & myDte & "#) " _
& "AND (Budget = " & AmountEuro & " " _
& "AND (Description = '" & Description & "') ;"
-----------