So I think I have updated the code to what you are saying:
Added FROM (hopefully in the right spot)
Removed the setwarnings (Am I doing that right by adding ' to the front of the line?)
Code:
Private Sub Command151_Click()On Error GoTo Err_Handler
Dim strSQL As String
strSQL = "INSERT INTO ExitingStaffData (ExitingStaffID, ExitingStaff , SupervisorDetails , ExecAccessCard , IDAccessCard , 33CAccessCard )"
strSQL = strSQL & " SELECT id, ExitingStaff , SupervisorDetails , ExecAccessCard , IDCard , 33CAccessCard FROM Cardsmaintainedbyfacilities"
'DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
'DoCmd.SetWarnings True
MsgBox "Record has been transferred"
Me.Command151.Enabled = False
Me.Recordhasbeentransferred = True
Me.Card_returned.Locked = True
Err_Exit:
Exit Sub
Err_Handler:
MsgBox Err.Description
Resume Err_Exit
End Sub
But I am still receiving the syntax error message in Syntax error (missing operator) in query expression '33CAccessCard'.
If I change the code to (ie remove reference to 33CAccessCard) code runs and the record data appears in the other table:
Code:
Private Sub Command151_Click()On Error GoTo Err_Handler
Dim strSQL As String
strSQL = "INSERT INTO ExitingStaffData (ExitingStaffID, ExitingStaff , SupervisorDetails , ExecAccessCard , IDAccessCard )"
strSQL = strSQL & " SELECT id, ExitingStaff , SupervisorDetails , ExecAccessCard , IDCard FROM Cardsmaintainedbyfacilities"
'DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
'DoCmd.SetWarnings True
MsgBox "Record has been transferred"
Me.Command151.Enabled = False
Me.Recordhasbeentransferred = True
Me.Card_returned.Locked = True
Err_Exit:
Exit Sub
Err_Handler:
MsgBox Err.Description
Resume Err_Exit
End Sub
Just a question - is it because I have numbers in the descriptor? Its the only thing I can think of thats different??