Is accessing the current time and waiting for it to change possible?

  • Thread starter Thread starter nasuno via AccessMonster.com
  • Start date Start date
N

nasuno via AccessMonster.com

Hello everyone.

When our product comes through our packaging department, the boxes
information gets entered into our database and labels printed out. The
boxes all have a reference number that depends on the date and time of day.
Therefore if two new records are created within the same minute ( I am not
allowed to narrow this down) then we have two boxes with the same box
number. That's bad.
I need this button to not be active until the time the current record
started has changed to the next minute.


Private Sub Command32_Click()
On Error GoTo Err_Command32_Click


DoCmd.GoToRecord , , acNewRec

Exit_Command32_Click:
Exit Sub

Err_Command32_Click:
MsgBox Err.Description
Resume Exit_Command32_Click

End Sub


Any ideas? Thanks.
 
After you click on the button the first time, disable the button and set the
form's TimerInterval property. You can either set it for 60000 (60 seconds),
or you can determine how many seconds until the next minute, and set it to
1000 times that. In either case, put code in the form's Timer event to
reenable the button.
 
I don't know how you are carrying the date in the table, but it seems to me a
simple approach would be to carry the date in the table as a long date. That
would get you down to the second and eliminate the duplicates problem. How
you display the date can be handled on your forms and reports.
 
Klatuu: I am not allowed to change how the boxnumbers are generated.
so I am trying Douglas J. Steele's approach. I am not a too good at this by
any means so I will post back when (If) I get it working.
Thanks both of you.
 
It seems to me that Steele's approach would be the simplest. When I read
your post, I thought about how I would handle it before I read the replies
and my solution and Steele's were about identical.
after your

DoCmd.GoToRecord , , acNewRec

add

me!command32.enabled=false

that'll disable your button.

in your forms properties, set the timer interval to 60000 (measured in
milliseconds, thats 1000 milliseconds * 60 seconds)

and add an event procedure to your forms 'on timer' property that would
have the command in it:

me!command32.enabled=true

all thats really doing is re-enabling your command32 button every 60000
milliseconds. (thats what you set your timer interval to and so every time
that number of milliseconds goes by, the on timer event runs.)

what this will effectively do is not allow your users to click on the
button again until after the forms 60 second timer hits. and since theres
only 60 seconds in a minute, your guaranteed to not have your button re-
enabled until sometime into the next minute.
 
This is probably pretty simple to you all. Sorry. I'm still having this
little problem :)
I am getting:
You can't disable a control while it has the focus.
when I put me!command32.enabled=false after DoCmd.GoToRecord , , acNewRec
Thanks you all for your time trying to help me.
 
Fixed that :) Now I am getting:
Object doesn't support this property or method.
This is getting fun :)
 
Sorry about the 'cant disable a control while it has focus' error. that was
a brain fart. you have to SetFocus on some other object on your form before
disabling the button. Is that what you did to fix it? (me!'some other
object name'.setfocus)?

can you copy and paste the code for your forms module? or at least for the
section of code thats causing the 'control doesnt support this property or
method'. We'll see if we cant figure out what caused it.
 
Back
Top