PC Review


Reply
Thread Tools Rate Thread

ECHO Causing Problems

 
 
DS
Guest
Posts: n/a
 
      13th May 2005
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?
Thanks
DS
 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      13th May 2005
"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.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
DS
Guest
Posts: n/a
 
      13th May 2005
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
 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      13th May 2005
"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)


 
Reply With Quote
 
DS
Guest
Posts: n/a
 
      13th May 2005
Dirk Goldgar wrote:
> "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.
>

Thanks Dirk,
But you say use DLookup...? I would love to not have to create and open
all of these forms, I suspect it would be a little cleaner!
Perhaps a little sample just to get me started....
Thanks
DS
 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      17th May 2005
"DS" <(E-Mail Removed)> wrote in message
news:7k8he.10191$(E-Mail Removed)
> Thanks Dirk,
> But you say use DLookup...? I would love to not have to create and
> open all of these forms, I suspect it would be a little cleaner!
> Perhaps a little sample just to get me started....
> Thanks


Remember that data is stored in tables, not in forms -- forms only
*present* the data, for viewing and editing. You can examine this data
in code by opening recordsets on the the table (or on queries of the
tables ) -- this is the complicated way -- or by using the domain
aggregate functions DLookup, DMax, DMin, DSum, etc. -- this is the
simple way. If all your code needs is to know the value of one or more
fields in a table, there's no need to incur the overhead of opening a
user-interface object like a form.

It's impossible for me to give you a good working example, because I
don't know what tables or queries are the recordsources of your forms.
But look at this code of yours:

> DoCmd.OpenForm "EmpIDLog", acNormal, "", "", , acNormal
> If (Forms!EmpIDLog!EmployeeID <= 0) Then


It looks as though you are opening this form for two purposes: first,
to check whether there is an employee logged in, and then -- I think --
to provide that employee's EmployeeID to another form. For the first
purpose, code like this might suffice:

Dim lngEmployeeID As Long

lngEmployeeID = DLookup("EmployeeID", "tblEmpIDLog")

That assumes that "tblEmpIDLog" is the name of the table on which form
"EmpIDLog" is based, that it has a field named "EmployeeID", and that --
this is important -- there is no need to apply any criteria or sort to
get the specific record we need to look up. If it's necessary to apply
criteria to select a specific record, that can be done with DLookup. If
a sort is necessary, then you really need to use a query as the basis of
the DLookup, rather than the table itself.

It's hard to say exactly what to do about the second purpose -- if I've
guessed right about it at all -- because I don't know any of the
details. But suppose that it's form "TimeLog" that you want to open,
and that the recordsource of that form is currently a query that refers
to Forms!EmpIDLog!EmployeeID, like this:

SELECT * FROM tblTimeLog
WHERE EmployeeID = [Forms]![EmpIDLog]![EmployeeID];

If you changed that recordsource to just the table:

tblTimeLog

then you could open it to show records for the employee whose EmployeeID
you just looked up, like this:

DoCmd.OpenForm "TimeLog", _
WhereCondition:="EmployeeID = " & lngEmployeeID

That's the best I can do for an example, given how little I know about
your application's structure.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
NF325-A7 Sound problem: sounds like an echo ,,echo...echo makes me crazy...crazy...crazy...help...help...help David Sontag DIY PC 17 30th Nov 2007 06:45 AM
applicaton.echo / docmd.echo screen still pulsing - Why? Rick A Microsoft Access Form Coding 1 30th Mar 2006 04:01 AM
MSN Messenger 6.2 - Problems with ECHO =?Utf-8?B?Sm9uLmJvbg==?= Windows XP Messenger 9 2nd Aug 2004 01:03 AM
Echo problems Gary Windows XP Messenger 1 8th Apr 2004 10:30 PM
Echo problems gary Windows XP Messenger 0 6th Apr 2004 05:42 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:24 PM.