GO TO TODAY button

iankerry

Registered User.
Local time
Today, 06:51
Joined
Aug 10, 2005
Messages
190
Hi,

I have an events database with 500 different events in it. I have built it from scratch but very slowly over the years.

On a continuous form I have a GO TO TODAY button which goes to the record for today. If there is one.

[datefield].SetFocus
RunCommand acCmdSortAscending
DoCmd.FindRecord Date

Is there some code I can use for the days when I don't have an event, but I want to go to the day nearest today but after it. So if the date was 2/10/07, but I didn't have a record/event for that day, it would go to the record for the 5/10/07 when I do have one.

many thanks

ian
 
Ian,

Dim dtmBestDate As Date
dtmBestDate = DMax("[YourDateField]", "YourTable", "[YourDateField] >= #" & Date & "#")

Then use dtmBestDate in the DoCmd.FindRecord

hth,
Wayne
 
Hi Wayne

Thanks very much for replying. Mixed success with using the dmax. The record is chooses to go to is the last in the database!

when trying to find out why i put a watch on it, and on the Dim command the dtmbestdate= to last date in the database.

any ideas? i have tried to play around with to understand it more but i cant get any further. thanks

ian
 

Users who are viewing this thread

Back
Top Bottom