T
thefonz37
Let me preface by saying that in my database, I am storing employee
information inside of two tables - one for general information (Employee ID
#, name, hire date, supervisor name, etc), and one for login information into
our various business applications. These tables are joined on Employee ID
fields, which are text values in both tables.
I'm trying to design a form where users can edit employee data, but the
problem is that if somebody modifies an employee ID, it no longer associates
the employee properly with their logins, as this is the key that joins the
two. So I tried to write some code related to the Employee ID box on the
form to update the login table with the new data:
Dim oldEmpID As String
Private Sub EmpID_AfterUpdate()
Dim sqlQry As String
sqlQry = "UPDATE [Logins_Data] SET [Logins_Data].EmpID = [Forms]![Edit
Employee Data]![EmpID] WHERE [Logins_Data].EmpID=" & oldEmpID & ";"
DoCmd.RunSQL sqlQry
If Me.Dirty Then
Me.Dirty = False
End If
End Sub
Private Sub EmpID_Change()
oldEmpID = [Forms]![Edit Employee Data]![EmpID]
End Sub
Everything works ok if I replace "oldEmpID" with any other value in the SQL
Update statement, but if I leave it as it is above, I get a type mismatch. I
don't get it because oldEmpID and the EmpID field of the login table is text.
information inside of two tables - one for general information (Employee ID
#, name, hire date, supervisor name, etc), and one for login information into
our various business applications. These tables are joined on Employee ID
fields, which are text values in both tables.
I'm trying to design a form where users can edit employee data, but the
problem is that if somebody modifies an employee ID, it no longer associates
the employee properly with their logins, as this is the key that joins the
two. So I tried to write some code related to the Employee ID box on the
form to update the login table with the new data:
Dim oldEmpID As String
Private Sub EmpID_AfterUpdate()
Dim sqlQry As String
sqlQry = "UPDATE [Logins_Data] SET [Logins_Data].EmpID = [Forms]![Edit
Employee Data]![EmpID] WHERE [Logins_Data].EmpID=" & oldEmpID & ";"
DoCmd.RunSQL sqlQry
If Me.Dirty Then
Me.Dirty = False
End If
End Sub
Private Sub EmpID_Change()
oldEmpID = [Forms]![Edit Employee Data]![EmpID]
End Sub
Everything works ok if I replace "oldEmpID" with any other value in the SQL
Update statement, but if I leave it as it is above, I get a type mismatch. I
don't get it because oldEmpID and the EmpID field of the login table is text.