maximo1970
ISP
Got this code, but getting an error when I call the Function within a form.
Run-Time error `3075`:
Syntax error (missing operator) in query expression `Customer = John Smith`.
The code stop's at : Set RS = DB.OpenRecordset(sSQL)
I've been looking at it for most of the morning and can't see where the problem is. So any pointers.
Cheers
Function UpdateCustomers() As String
Dim sSQL As String
Dim DB As Database
Dim RS As Recordset
sSQL = "SELECT * FROM tbl_Customer_Details " & _
"WHERE Customer = " & [Forms]![frm_Allocate_VLAN]![Customer]
Set DB = CurrentDb
Set RS = DB.OpenRecordset(sSQL)
If Not RS.EOF Then
RS.MoveLast
RS.MoveFirst
End If
If RS.RecordCount < 1 Then
sSQL = "INSERT INTO [tbl_Customer_Details] VALUES (" & [Forms]![frm_Allocate_VLAN]![Customer] & "
"
Call DB.Execute(sSQL)
End If
RS.Close
DB.Close
Set RS = Nothing
Set DB = Nothing
End Function
Run-Time error `3075`:
Syntax error (missing operator) in query expression `Customer = John Smith`.
The code stop's at : Set RS = DB.OpenRecordset(sSQL)
I've been looking at it for most of the morning and can't see where the problem is. So any pointers.
Cheers
Function UpdateCustomers() As String
Dim sSQL As String
Dim DB As Database
Dim RS As Recordset
sSQL = "SELECT * FROM tbl_Customer_Details " & _
"WHERE Customer = " & [Forms]![frm_Allocate_VLAN]![Customer]
Set DB = CurrentDb
Set RS = DB.OpenRecordset(sSQL)
If Not RS.EOF Then
RS.MoveLast
RS.MoveFirst
End If
If RS.RecordCount < 1 Then
sSQL = "INSERT INTO [tbl_Customer_Details] VALUES (" & [Forms]![frm_Allocate_VLAN]![Customer] & "
Call DB.Execute(sSQL)
End If
RS.Close
DB.Close
Set RS = Nothing
Set DB = Nothing
End Function