Startup question.

  • Thread starter Thread starter glen
  • Start date Start date
G

glen

I am able to use the startup to opent the database to my "main form".
The form opens to the first record date. I would like the form to open to
today's date. I have not been able to accomplish this and could use some
help. thanks in advance.
 
glen said:
I am able to use the startup to opent the database to my "main form".
The form opens to the first record date. I would like the form to open to
today's date. I have not been able to accomplish this and could use some
help.


If the form's records are sorted in date ascending order,
then you can use code in the form's Load evevy procedure to
move to the last record:

If Me.Recordset.RecordCount > 0 Then
Me.Recordset.MoveLast
End If

If there's no guarantee that a record for today's date
exists, then you will get the latest date in the table.

If you have records for future dates, then you can try to
find a record with today's date instead:

With Me.Recordset
If .RecordCount > 0 Then
.FindFirst "thedatefield = Date()"
If .NoMatch Then
???
End If
End If
End With

The ??? are for whatever you want to do when there is no
record for today's date.
 
Back
Top