"DS" <(E-Mail Removed)> wrote in message
news:5L6he.1802$(E-Mail Removed)
> Dirk Goldgar wrote:
>> "DS" <(E-Mail Removed)> wrote in message
>> news:GD4he.1018$(E-Mail Removed)
>>
>>> I wrote a Macro using Echo On, Echo Off....It works great! I
>>> converted it to code, It doesn't work so great, in fact it keeps
>>> freezing up the screen. Whenever I take the Echo out of the
>>> equation it works fine but I can see all of the action. Are there
>>> pitfalls with this Echo thing? Any other way to do this?
>>
>>
>> Show your code. Your "freezing up" problem could be due to an
>> unhandled error leaving Echo turned off, a message or prompt being
>> displayed and waiting for acknowledgement, but unseen because Echo
>> is off, or just a long-running process leaving the impression that
>> you are locked up. Use Echo False very sparingly, and extremely
>> carefully.
>>
> 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.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)