autofill a date sometimes, not always.. .... best way

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

Guest

hi,
I have a basic form that has a date field. I would like to populate the
date field automatically from the previous record. I think I can do that, but
when I am on the first record, I dont have a date field really to use - the
previous record entry could be from a date two weeks ago, so I dont want to
use it. I thought of just using current date, but they dont want that. I have
the following so far, but it doesnt work on the first record. I am not sure
what to do. How do I check for the first entry? thanks-

Private Sub DateLog_AfterUpdate()
DateValue = Me.DateLog.Value
End Sub

Private Sub DateLog_GotFocus()

If Not IsNull(Me.NewRecord) Then
Me.DateLog.Value = DateValue
End If

End Sub
 
hi,
I have a basic form that has a date field. I would like to populate the
date field automatically from the previous record. I think I can do that, but
when I am on the first record, I dont have a date field really to use - the
previous record entry could be from a date two weeks ago, so I dont wantto
use it. I thought of just using current date, but they dont want that. Ihave
the following so far, but it doesnt work on the first record. I am not sure
what to do. How do I check for the first entry? thanks-

Private Sub DateLog_AfterUpdate()
DateValue = Me.DateLog.Value
End Sub

Private Sub DateLog_GotFocus()

If Not IsNull(Me.NewRecord) Then
Me.DateLog.Value = DateValue
End If

End Sub

Is the latest date entered also the latest of all dates in that
column? If so, you can use the DMax() function on it.
 
Thanks Bob, I figured it out..
Bob Hairgrove said:
Is the latest date entered also the latest of all dates in that
column? If so, you can use the DMax() function on it.
 

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