Go To Current Date

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

Guest

Hello.
I have two tables and they are relate by a One to Many relationship and I
have a Form with Subform.
The parent table has only one field ScheduleDate and in this field I have
imported dates from now to 1/1/2009.
In the Sub table I have the following fields
ScheduleDate
LoginTime
LogoutTime

When I open the Parent Form I need it to go to Todays date so that we can
see all the subform records for today i.e. if today is 5/20/07 when I open
the form it takes me straight to 5/20/07 but without filtering out all the
other records in case I need to look at other dates around 5/20/07.
I would hate to have to open the database and have to scroll to find today's
date.
Is it possible to do this?

Iram/mcp
 
Iram said:
I have two tables and they are relate by a One to Many relationship and I
have a Form with Subform.
The parent table has only one field ScheduleDate and in this field I have
imported dates from now to 1/1/2009.
In the Sub table I have the following fields
ScheduleDate
LoginTime
LogoutTime

When I open the Parent Form I need it to go to Todays date so that we can
see all the subform records for today i.e. if today is 5/20/07 when I open
the form it takes me straight to 5/20/07 but without filtering out all the
other records in case I need to look at other dates around 5/20/07.
I would hate to have to open the database and have to scroll to find today's
date.


Use the form's Load event procedure:

Me.Recordset.FindFirst "ScheduleDate=" _
Format(Date, "\#m\/d\/yyyy\#")
 
I copied the contents below and put it into the On Load Event Procedure and
it looks like this:

Private Sub Form_Load()
Me.Recordset.FindFirst "ScheduleDate="
Format(Date, "\#m\/d\/yyyy\#")
End Sub

But the first line beomes highlighted in Yellow "Private Sub Form_Load()"
and the third line turned Red "Format(Date, "\#m\/d\/yyyy\#")"


Iram/mcp
 
It appears to be missing the & between the two items...

Me.Recordset.FindFirst "ScheduleDate=" & Format(Date, "\#m\/d\/yyyy\#")

Hope this helps.

Damian.
 
I copied yours into the Event Procedure and replaced Marshal's and when I
open the form it doesn't go to the current date. It just opens and goes to
the first record.
Should I have the "ScheduleDate" field formatted in a special way?
I have "ScheduleDate" as the field name in the form and it is the actual
table field name to. Is that ok? There is a subform as well will that make a
difference. The subform has a "scheduledate field name too.
 
Iram said:
I copied yours into the Event Procedure and replaced Marshal's and when I
open the form it doesn't go to the current date. It just opens and goes to
the first record.
Should I have the "ScheduleDate" field formatted in a special way?
I have "ScheduleDate" as the field name in the form and it is the actual
table field name to. Is that ok? There is a subform as well will that make a
difference. The subform has a "scheduledate field name too.


Sorry about the missing &

Now that we're past that issue, I'm wondering if your
ScheduleDate field is a Date field, or is it a text field
where you store strings that look like dates??

Also double check that the Load event procedure is actually
executing by adding a MsgBox "Load Event" to the procedure.
 
Fixed. Thanks. YOU ARE THE MAN!
The field was set to Text and I changed it to Date.
You are the MAN!

Iram/mcp
 
Back
Top