limit coding on "Prev" and "Next" button

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

Guest

I am creating a form for the user to log events that have happened on a
particular day. Once the day is done, they will create a new record at
midnite by selecting the "Next" button and enter the new date (or have the
data automatically be put in for "today" , if thats possible).
There's really no need for the user to edit data once the day is over. The
only reason would be if the computer went down for some reason shortly before
midnite and they were unable to finish entering a few entries at the end of
the day. Therefore, I would like them to be able only have access to
Yesterday and Today. Is there a way to code that on the two buttons. Or
maybe the 2 button could be labeled "Yesterday" and "Today", but even so, if
I use the acPrevious command, I don't want them to keep selecting it. I'm
assuming there some kind of an IF statement stating If the date is < "today's
date-1" ......., then a dialog box will pop up or the button can be grayed
out and not allowed to be selected. I just don't know how to write it.
Also, on the "Today" button, if "Today" has already been created, then don't
create a new one, just go back to the last record.

I hope I made myself clear. Thanks in advance for any help out there!


Patti
 
Hi Patti,

I'd be inclined to do this by basing the form on a query that only
returns records with today's and yesterday's date. If your event records
have a date/time field with the relevant time, it would be like this:

WHERE DateValue([TimestampField]) = Date()
OR DateValue([TimestampField]) = Date() - 1

or if the field just contains the date,
WHERE [DateStampField] = Date()
OR [DateStampField] = Date() - 1

Also, in table design view set the default value of the date field to
=Date()
 

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

Back
Top