Determine whether echo is on or off

  • Thread starter Bill R via AccessMonster.com
  • Start date
B

Bill R via AccessMonster.com

I have a procedure in a form that turns echo off at the beginning and on
again at the end. That's fine, except that when the procedure runs, it
requeries other subforms that also need to turn echo on and off in other
situations. So the problem is that when my procedure hands off to another
procedure that turns echo on and off, at the end of this second procedure
echo is turned off and remains so for the rest of the calling procedure.

I thought of 2 possible fixes:

1. Obviously, turn Echo off again after the second procedure hands off back
to the first one. But the screen updates momentarily between the 2 events.

2. I would prefer to set a blEcho boolean variable at the beginning of the
second procedure that will reflect the current condition of the Echo when the
procedure starts and replace Echo False at the end of the second procedure
with Echo blEcho. That way, when the second procedure runs under other
circumstances, if Echo was false when it began, it will be false when it ends,
but if Echo was true when the procedure began, it will not be set to false at
the end.

That leaves me with a problem. How do I set the blEcho variable to the Echo
condition at the start of the second procedure? I tested in the immediate
window a couple of obvious methods, but I can't find a way to determine
Echo's true/false setting. Any suggestions?

Thanks,

Bill
 
D

Douglas J. Steele

AFAIK, there is no way to determine the status.

However, it's your application, isn't it? Shouldn't you be the only one
changing the Echo?
 
B

Bill R via AccessMonster.com

Yes. But perhaps I didn't state it clearly. I have OnCurrent procedures
running in several forms that include Echo on/off. In many cases that is a
necessity. But when those forms are requeried by another procedure it is
preferable that they not turn echo on at the end. Most of the time it's a
requirement, but sometimes it's a problem. If the form is requeried in the
middle of a procedure that wants Echo off, Echo is on for the balance of the
calling procedure. Even setting it immediately to off results in a repaint.
It seems strange that Access and the application object know the status of
Echo, yet it's hidden from VBA. More's the pity.
The net result is that I have to decide whether to remove the Echo on/off
from the requeried form's OnCurrent procedure or settle for the momentary
repaint when it hands back to the calling procedure.

Bummer!

Bill
AFAIK, there is no way to determine the status.

However, it's your application, isn't it? Shouldn't you be the only one
changing the Echo?
I have a procedure in a form that turns echo off at the beginning and on
again at the end. That's fine, except that when the procedure runs, it
[quoted text clipped - 29 lines]
 
M

Marshall Barton

In the case where there is a lot of nested Echo on and off
going on, let me suggest that you create a simple Class
Module to manage it for you. This way, you could keep the
status of Echo on a push down list and use a PushAndSet and
a Pop method to deal with the situation you're describing.
--
Marsh
MVP [MS Access]

Yes. But perhaps I didn't state it clearly. I have OnCurrent procedures
running in several forms that include Echo on/off. In many cases that is a
necessity. But when those forms are requeried by another procedure it is
preferable that they not turn echo on at the end. Most of the time it's a
requirement, but sometimes it's a problem. If the form is requeried in the
middle of a procedure that wants Echo off, Echo is on for the balance of the
calling procedure. Even setting it immediately to off results in a repaint.
It seems strange that Access and the application object know the status of
Echo, yet it's hidden from VBA. More's the pity.
The net result is that I have to decide whether to remove the Echo on/off
from the requeried form's OnCurrent procedure or settle for the momentary
repaint when it hands back to the calling procedure.

AFAIK, there is no way to determine the status.

However, it's your application, isn't it? Shouldn't you be the only one
changing the Echo?
I have a procedure in a form that turns echo off at the beginning and on
again at the end. That's fine, except that when the procedure runs, it
[quoted text clipped - 29 lines]
 
B

Bill R via AccessMonster.com

I'm not sure I understand your suggestion. It would seem to imply that I
could determine the status of Echo, but that's precisely the problem. I can't
find any way to determine it's status.
Could you offer an example of a PushAndSet method?

Thanks,

Bill

Marshall said:
In the case where there is a lot of nested Echo on and off
going on, let me suggest that you create a simple Class
Module to manage it for you. This way, you could keep the
status of Echo on a push down list and use a PushAndSet and
a Pop method to deal with the situation you're describing.
Yes. But perhaps I didn't state it clearly. I have OnCurrent procedures
running in several forms that include Echo on/off. In many cases that is a
[quoted text clipped - 17 lines]
again at the end. That's fine, except that when the procedure runs, it
[quoted text clipped - 29 lines]
 
M

Marshall Barton

You know that Echo is on when your app first opens. If you
then always use a procedure to save the status when setting
it, you will always be able to restore it when you're done
with a particular action.

The simple example of the kind of code (below) would allow
you to set echo for any of your procedures and restoring it
when the procedure is done without regard for what the
status of echo was before your procedure started:

Echo PushAndSet(True) 'Initialize before anything else
. . .
Echo PushAndSet(False) ' in first procedure
Echo PushAndSet(False) ' in nested procedure
Echo Pop 'end of nested procedure
Echo Pop 'end of first procedure

I changed my mind to using functions in a standard module
instead of a class module so be careful about resetting your
app in the middle of this stuff. Anyway, here's the
slightly tested outline of this kind of code:

Private aryStack(0 To 100) As Boolean
Private bolStatus As Boolean
Private intPos As Integer

Public Function PushAndSet(OnOff As Boolean)
If intPos > UBound(aryStack) Then
MsgBox "echo stack overflow"
Stop
End If
'Save current status onto push down list
aryStack(intPos) = bolStatus
intPos = intPos + 1
'Set new status
bolStatus = OnOff
PushAndSet = bolStatus
End Function

Public Function Pop()
'Restore value from list
If intPos > 1 Then 'first value is never removed
intPos = intPos - 1
End If
bolStatus = aryStack(intPos)
Pop = bolStatus
End Function
--
Marsh
MVP [MS Access]

I'm not sure I understand your suggestion. It would seem to imply that I
could determine the status of Echo, but that's precisely the problem. I can't
find any way to determine it's status.
Could you offer an example of a PushAndSet method?


Marshall said:
In the case where there is a lot of nested Echo on and off
going on, let me suggest that you create a simple Class
Module to manage it for you. This way, you could keep the
status of Echo on a push down list and use a PushAndSet and
a Pop method to deal with the situation you're describing.
Yes. But perhaps I didn't state it clearly. I have OnCurrent procedures
running in several forms that include Echo on/off. In many cases that is a
[quoted text clipped - 17 lines]
again at the end. That's fine, except that when the procedure runs, it
[quoted text clipped - 29 lines]
 
B

Bill R via AccessMonster.com

Marshall,

Thanks a million. I will implement this.

Bill

Marshall said:
You know that Echo is on when your app first opens. If you
then always use a procedure to save the status when setting
it, you will always be able to restore it when you're done
with a particular action.

The simple example of the kind of code (below) would allow
you to set echo for any of your procedures and restoring it
when the procedure is done without regard for what the
status of echo was before your procedure started:

Echo PushAndSet(True) 'Initialize before anything else
. . .
Echo PushAndSet(False) ' in first procedure
Echo PushAndSet(False) ' in nested procedure
Echo Pop 'end of nested procedure
Echo Pop 'end of first procedure

I changed my mind to using functions in a standard module
instead of a class module so be careful about resetting your
app in the middle of this stuff. Anyway, here's the
slightly tested outline of this kind of code:

Private aryStack(0 To 100) As Boolean
Private bolStatus As Boolean
Private intPos As Integer

Public Function PushAndSet(OnOff As Boolean)
If intPos > UBound(aryStack) Then
MsgBox "echo stack overflow"
Stop
End If
'Save current status onto push down list
aryStack(intPos) = bolStatus
intPos = intPos + 1
'Set new status
bolStatus = OnOff
PushAndSet = bolStatus
End Function

Public Function Pop()
'Restore value from list
If intPos > 1 Then 'first value is never removed
intPos = intPos - 1
End If
bolStatus = aryStack(intPos)
Pop = bolStatus
End Function
I'm not sure I understand your suggestion. It would seem to imply that I
could determine the status of Echo, but that's precisely the problem. I can't
[quoted text clipped - 6 lines]
status of Echo on a push down list and use a PushAndSet and
a Pop method to deal with the situation you're describing.
Yes. But perhaps I didn't state it clearly. I have OnCurrent procedures
running in several forms that include Echo on/off. In many cases that is a
[quoted text clipped - 17 lines]
again at the end. That's fine, except that when the procedure runs, it
[quoted text clipped - 29 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top