I can't seem to get this one to work. I have looked all over the web, found many examples but can't get the syntax right for some reason. Please help.
When I click a button on a particular form, VBA code runs to update several fields on the table behind the form (tblComm).
Private Sub TermUser_Click()
'Add a string variable,
Dim strUN As String
'set the string variable to the contents of the text boxes
strUN = Me![First Name] & " " & Me![Last Name]
'Copy First and Last Name of user to the text box Former User
[Former Employee] = strUN
'clear First Name text box
[First Name] = ""
'Change Last Name text box to Open
[Last Name] = "Open"
[DirectoryYN] = No
End Sub
Now I am trying to add another line that will also update the Status column in another table (tblEmployee) to change the status the employee to "Terminated" using the Employee's ID (EMPLID)
CurrentDb.Execute "UPDATE tblEmployee SET tblEmployee.[Status] = 'Terminated' " _
"WHERE tblEmployee.[EMPLID] = " & Me![EMPLID]
The VBA worked fine till I added this line.
Now I get a compile error.
I'm sure it is a syntax problem but I'm following the examples from Microsoft. Apparently not well enough though.
Any suggestions would be greatly appreciated.
Thanks.
When I click a button on a particular form, VBA code runs to update several fields on the table behind the form (tblComm).
Private Sub TermUser_Click()
'Add a string variable,
Dim strUN As String
'set the string variable to the contents of the text boxes
strUN = Me![First Name] & " " & Me![Last Name]
'Copy First and Last Name of user to the text box Former User
[Former Employee] = strUN
'clear First Name text box
[First Name] = ""
'Change Last Name text box to Open
[Last Name] = "Open"
[DirectoryYN] = No
End Sub
Now I am trying to add another line that will also update the Status column in another table (tblEmployee) to change the status the employee to "Terminated" using the Employee's ID (EMPLID)
CurrentDb.Execute "UPDATE tblEmployee SET tblEmployee.[Status] = 'Terminated' " _
"WHERE tblEmployee.[EMPLID] = " & Me![EMPLID]
The VBA worked fine till I added this line.
Now I get a compile error.
I'm sure it is a syntax problem but I'm following the examples from Microsoft. Apparently not well enough though.
Any suggestions would be greatly appreciated.
Thanks.