error 3134 with Insert Into Statement

dnrhymer4

Registered User.
Local time
Today, 11:30
Joined
Mar 1, 2010
Messages
12
Hi Folks,

I need some help. I have a form with a combo box bound to Table 2. I am trying to write an Insert Into Statement that will add the value to Table 1(Account Number Dump) in the On Change event. I keep getting Error '3134' Syntax Error in Insert Into Statement. Can anyone tell me what I'm doing wrong?:confused:

Private Sub Account_Number_Change()
Dim strSQL As String
If Me.Account_Number = DLookup("[Budget Account]", "Account Number Dump", "[Manager] = '" & Me.Manager & "'") Then
Else
strSQL = "INSERT INTO [Account Number Dump] (Manager, Budget Account) Values ('" & Me.Manager & "', '" & Me.Account_Number & "');"
Debug.Print strSQL
CurrentDb.Execute strSQL
End If
End Sub

My debug gives me:
INSERT INTO [Account Number Dump] (Manager, Budget Account) Values ('Randall', '30-638-5540');
 
Budget Account

needs square brackets since you have a space:

[Budget Account]
 
And then also, are these both text fields?

Manager, [Budget Account]
 
I now have this, but it's still not writing to the table:
Private Sub Account_Number_Change()
Dim strSQL As String
If Me.Account_Number = DLookup("[Budget Account]", "Account Number Dump", "[Manager] = '" & Me.Manager & "'") Then
Else
strSQL = "INSERT INTO [Account Number Dump] (Manager, [Budget Account]) Values ('" & Me.Manager & "', '" & Me.Account_Number & "');"
Debug.Print strSQL
CurrentDb.Execute strSQL
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom