DS said:
My Code........Thanks DS
On Error GoTo LogOnID_Err
DoCmd.Echo False, ""
' Open EmpID Log Form
DoCmd.OpenForm "EmpIDLog", acNormal, "", "", , acNormal
If (Forms!EmpIDLog!EmployeeID <= 0) Then
' Open Invalid ID Log On Form
DoCmd.OpenForm "InvalidIDLog", acNormal, "", "", , acNormal
' Close EmpID Log Form
DoCmd.Close acForm, "EmpIDLog"
' Close Log On Form
DoCmd.Close acForm, "LogOn"
' Stops Macro
Exit Sub
End If
' Opens Time Log Form
DoCmd.OpenForm "TimeLog", acNormal, "", "", , acNormal
If (IsNull(Forms!TimeLog!EmployeeID)) Then
' Opens Not Signed Log Form
DoCmd.OpenForm "NotSignedInLog", acNormal, "", "", , acNormal
' Close Time Log Form
DoCmd.Close acForm, "TimeLog"
' Close EmpID Log Form
DoCmd.Close acForm, "EmpIDLog"
' Close Log On Form
DoCmd.Close acForm, "LogOn"
' Stops Macro
Exit Sub
End If
If (Forms!EmpIDLog!EmployeeID > 0) Then
' Open Time Log Form
DoCmd.OpenForm "TimeLog", acNormal, "", "", , acNormal
' Go to Last Record of EmployeeID
DoCmd.GoToRecord , "", acLast
' Close EmpID Log Form
DoCmd.Close acForm, "EmpIDLog"
End If
If (Forms!TimeLog!DateOut > 0) Then
' Opens Not Signed In Log Form
DoCmd.OpenForm "NotSignedInLog", acNormal, "", "", , acNormal
' Close EmpID Log Form
DoCmd.Close acForm, "EmpIDLog"
' Close Time Log Form
DoCmd.Close acForm, "TimeLog"
' Close Log On Form
DoCmd.Close acForm, "LogOn"
' Stops Macro
Exit Sub
End If
If (IsNull(Forms!TimeLog!DateOut)) Then
' Opens Tables Form
DoCmd.OpenForm "Tables", acNormal, "", "", , acNormal
Forms!Tables!Text16 = Forms!LogOn!Display
' Close Time Log Form
DoCmd.Close acForm, "TimeLog"
' Close Log On
DoCmd.Close acForm, "LogOn"
' Close EmpID Log Form
DoCmd.Close acForm, "EmpIDLog"
Exit Sub
End If
DoCmd.Echo True, ""
LogOnID_Exit:
Exit Sub
LogOnID_Err:
MsgBox Error$
Resume LogOnID_Exit
End Sub
All of those places before LogOnID_Exit where you execute the statement
"Exit Sub" will leave Echo set to False, resulting in an apparently
locked application. Also, if an error is raised, the Resume statement
in the error-handler is going to cause the procedure to exit without
resetting Echo to True. Furthermore, the error message won't be
visible, because Echo is still set to False at the moment it would be
displayed.
While I strongly suspect this code could be rewritten to check values in
tables rather than opening and closing forms just to read values from
them, that's beyond the scope of your question. Here's a minimally
revised version of your code:
'----- start of revised code -----
On Error GoTo LogOnID_Err
DoCmd.Echo False, ""
' Open EmpID Log Form
DoCmd.OpenForm "EmpIDLog", acNormal, "", "", , acNormal
If (Forms!EmpIDLog!EmployeeID <= 0) Then
' Open Invalid ID Log On Form
DoCmd.OpenForm "InvalidIDLog", acNormal, "", "", , acNormal
' Close EmpID Log Form
DoCmd.Close acForm, "EmpIDLog"
' Close Log On Form
DoCmd.Close acForm, "LogOn"
Else
' Opens Time Log Form
DoCmd.OpenForm "TimeLog", acNormal, "", "", , acNormal
If (IsNull(Forms!TimeLog!EmployeeID)) Then
' Opens Not Signed Log Form
DoCmd.OpenForm "NotSignedInLog", acNormal, "", "", ,
acNormal
' Close Time Log Form
DoCmd.Close acForm, "TimeLog"
' Close EmpID Log Form
DoCmd.Close acForm, "EmpIDLog"
' Close Log On Form
DoCmd.Close acForm, "LogOn"
Else
If (Forms!EmpIDLog!EmployeeID > 0) Then
' Open Time Log Form
DoCmd.OpenForm "TimeLog", acNormal, "", "", , acNormal
' Go to Last Record of EmployeeID
DoCmd.GoToRecord , "", acLast
' Close EmpID Log Form
DoCmd.Close acForm, "EmpIDLog"
End If
If (Forms!TimeLog!DateOut > 0) Then
' Opens Not Signed In Log Form
DoCmd.OpenForm "NotSignedInLog", acNormal, "", "", ,
acNormal
' Close EmpID Log Form
DoCmd.Close acForm, "EmpIDLog"
' Close Time Log Form
DoCmd.Close acForm, "TimeLog"
' Close Log On Form
DoCmd.Close acForm, "LogOn"
Else
If (IsNull(Forms!TimeLog!DateOut)) Then
' Opens Tables Form
DoCmd.OpenForm "Tables", acNormal, "", "", ,
acNormal
Forms!Tables!Text16 = Forms!LogOn!Display
' Close Time Log Form
DoCmd.Close acForm, "TimeLog"
' Close Log On
DoCmd.Close acForm, "LogOn"
' Close EmpID Log Form
DoCmd.Close acForm, "EmpIDLog"
End If
End If
End If
End If
LogOnID_Exit:
DoCmd.Echo True, ""
Exit Sub
LogOnID_Err:
DoCmd.Echo True, ""
MsgBox Error$
Resume LogOnID_Exit
End Sub
'----- end of revised code -----
Watch for line-wraps in the above, caused by the newsreader.
That ought to make it work without a major overhaul, but you wouldn't
need to turn echo off if you looked up values in tables (probably using
DLookup) rather than opening forms to get values from them.