Go To Now()

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

Guest

Hello.
I have created an Access Database to track my tasks. In the design I
imported all the dates from now through 2030 in a field called "TaskDate".

Currently when I open the task form it takes me to the first record then I
have to scroll through the records to the current date. I need it to go to
the current date upon opening the form.

Currently I am trying to get a "Go To Record" macro...
Object Type: Form
Object Name: frm_Taskform
Record: Go To
Offset: =Date() (The offset field can take any type of expression)

This is not working. How do I change it to get it to work?

Your help is greatly appreciated.

Iram/mcp
 
Offset is intended to be an integer that indicates the record number of the
target record.

Access stores dates as the number of days relative to 30 Dec, 1899. That
means that today (18 Mar, 2007) is 39159, so that specifying Date as the
offset is telling Access to move to the 39159th record in the recordset. I
suspect you don't have that many records...

If your recordset is sorted in ascending date order, you want to subtract
the value of the first date in the recordset from today's date in order to
get the desired record number.
 
How would I write that in the "Offset"?

Would this work if say tomorrow I opened the db, would it go to tomorrow's
data automatically? I plan on puting this macro on the "On Open" field Event
of the form so that whenever I open the db it goes to the current date.
 
Personally, I never use macros, so I'm obviously biased towards VBA. <g>

Karl's suggestion of using FindRecord might be appropriate.

Assuming you do have one record for every day since Feb 9, 2007, you should
be able to calculate the appropriate value for Offset as

DateDiff("d", #02/09/2007#, Date())
 
Back
Top