Command Button Work once a day

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible to make a command button work once and then not work until the
next day?

I have a DB that goes out to excel and copies all the info from excel and
puts the info into the DB. The people who use the DB forget if they imported
the data from excel into the Db and they do it twice or sometimes three
times. I have to go and delete the data that is DUP.

I would like the button to work once and then not work until the next day or
maybe put a 12 hour timer on the button.

Thanks
 
CrazyHorse,
A simple way would be to create a table called tblOneTime, with just two
fields... ButtonName and LastRun field. Say your Import button is called
cmdImport.
ButtonName LastDate
cmdImport 1/1/06
When you click the button on your form, DLookup (via ButtonName) the
LastDate in tblOneTime. If it's equal to [Date] then post message "Already
Run Today", and exit the sub. If [Date] Greater than LastRun, allow the
Import.
Adjust that Date logic to suit your needs... DateDiff > 12 hours...
etc... etc...
 
Store the timestamp when the button was last clicked in a table. When the
button's clicked, check if it's time. If it is, update the table.

You could get more sophisticated, and check on the form's Open event whether
or not to enable the button, but you'd need to put code in elsewhere (the
Current event?) to check whether it's time to re-enable the button.
 
Back
Top