delaying a macro in access

  • Thread starter gggggggggggggggggggggggggggggggggggggg
  • Start date
G

gggggggggggggggggggggggggggggggggggggg

I would like to be able to delay the start of a macro or pause it for a short
period of 3 to 5 seconds if possible. I have been looking into some of the
other suggestions and unfortunately they don't seem to work for my
application. What I am trying to do is have information entered into a form
from a barcode scanner and once it has been entered into one field have the
focus move to the next field. The only user input allowed will be through
the barcode scanner (no mouse or keyboard will be available for other
inputs), so this would make message boxes and the like useless. I have
looked into the sleep command but I am not good with code at all so if
someone knows of a way to pause a macro I would really really really
appreciate it.
Thanks
 
S

Steve Schapel

Gggggggggggggggggggggggggggggggggggggg,

Use an OpenForm action in a macro, to open a form especially for the
purpose, and then put the remaining actions into a second macro. Assign
the second macro on the On Timer event property of the form, and set the
form's Timer Interval property to 3000 (i.e. 3 seconds). I guess you
would put a Close action at the end of the second macro to close the
form again.
 
G

gggggggggggggggggggggggggggggggggggggg

Thank-you for your help, unfortunately it doesn't quite accomplish what I
need it to. There are a couple of different fields on one form that will be
updated by the barcode scanner and your idea works very well if only one
field is being updated during each session. Let me give a more detailed
example of what I was trying to accomplish:

user comes in and scans barcode 1 which then enters the information into
field 1, a macro or code (but I am not very good with code) would move the
focus to the next field and then the user could scan barcode 2 and that would
be entered into field 2 and so on. The final field would end with a macro
that would save the information and start a new record for whenever the next
user needs to input the data.

I have tried the before and afterupdate, and on change features but because
the scanner enters the information as if it were typed (the program is
already set to the fastes speed for entering information) so any actions by
the computer are completed before the information is truly updated.

If you or anyone else has any other suggestions I would appreciate them.
Thanks
 
S

Steve Schapel

Gggggggggggggggggggggggggggggggggggggg,

What is the process by which the barcode scanner is entering information
into the database... does it place the data somehow into the currently
active control onthe form? I am not sure really what the problem is...
where in the process is the "delay" required? Do you simply mean you
want the moving of the focus to the next control to be automated?
 
G

gggggggggggggggggggggggggggggggggggggg

Thanks again for your time Steve,

I obtained a plug-in from the manufacturer of the barcode scanner so that it
could work directly with MSAccess. What happens when the scanner reads a
barcode is that information is direclty input into whatever field or control
has the focus. So when my form opens the first field the needs information
is blank and is given the focus so that who ever uses the barcode scanner the
information will go to that field (the information input into the field is of
varying lengths too which also complicates matters). Here is where the delay
is required. I would like the macro or code to set the focus to the next
control on the form after the first control is updated but no matter what I
do whether I have a macro run using the afterupdate property from the control
or the after change property, the macro runs too fast for the information
coming from the scanner and has already moved the focus to the next control
even before the scanner has finished entering the information. So the
information is then split some in the first control and the remainder in the
second control. So, I was hoping that I could delay the macro by 3 seconds
just to allow enough time for the scanner to finish putting the information
in. I had considered adding extra controls and then running extra queries to
add the information together but that seemed like a lot of extra work just
for a few second pause. Anyway, I hope this explains it better and I
appreciate your help and any other advice you can give.
Thanks.
 
S

Steve Schapel

Gggggggggggggggggggggggggggggggggggggg,

Ok, now I understand the situation a lot clearer, so thanks for the
further explanation.

Well, if you want to stick with macros, then I will stick with my
original suggestion, about using the form's Timer event. In your macro,
use a SetValue action, like this...
Action: SetValue
Item: [Form].TimerInterval]
Expression: 3000

Then, make another macro, which you will assign on the On Timer event
property of the form, like this...

Condition: [Screen].[ActiveControl].[Name]="YourFirstControl"
Action: GoToControl
Control Name: [YourSecondControl]
Condition: [Screen].[ActiveControl].[Name]="YourSecondControl"
Action: GoToControl
Control Name: [YourThirdControl]
...etc
Action: SetValue
Item: [Form].TimerInterval]
Expression: 0

I didn't try this, but see no reason why it won't work.

Otherwise there is a way to do this using VBA procedure, based on a
function like you will see at http://www.mvps.org/access/api/api0021.htm
 

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