Can someone please explain why this doesn't work? It's in the After Update part of cboEmpName.
Code:
Dim strEmp As String
strEmp = Me.cboEmpName
Me.txtEEmail = Nz(DLookup("EEmail", "qryLUEmpName", "[EName]=" & "'" & strEmp & "'"))
Me.cboMgr = Nz(DLookup("EMgr", "qryLUEmpName", "[EName]=" & "'" & strEmp & "'"))
Me.txtMgrE = Nz(DLookup("EMgrEmail", "qryLUEmpName", "[EName]=" & "'" & strEmp & "'"))
'Place the cursor to the appropriate field
If Len(Me.txtEEmail) < 2 Then
Me.txtEEmail.SetFocus
ElseIf Len(Me.cboMgr) < 2 Then
Me.cboMgr.SetFocus
ElseIf Len(Me.txtMgrE) < 2 Then
Me.txtMgrE.SetFocus
Else: Me.cboVstrName.SetFocus
End If
When I enter a name, I want the cursor to go to the EEmail field first if it is blank. If not, go to the EMgr field if it is blank. If not, then go to the MgrE field if it is blank. If all of these already have a value, then go to VstrName.
The email, manager & manager email fields are all blank. When I press Enter after the Employee Name, it goes to EMgr instead of EEmail.
If I add an address in EEmail in the table & go back to the form, the focus goes from cboEmpName to cboMgr like I want it to.
If I add the address and a manager name in the table, the cursor jumps to cboVstrName, skipping txtMgrE.
This seems so simple, but I am not seeing what is going wrong.
Any ideas? Thanks!