Set the default value on a form

  • Thread starter Thread starter Keith
  • Start date Start date
K

Keith

I am trying to set the default value for a date field on a form to the day
after the last date already in the table. So when I click to enter a new
record, the date field has the first day that has not already been inputted.
I am sure it is incredibly simple, but I am struggling.

Thanks for your help
 
Use the BeforeInsert event procedure of the form. It will lookup the date
and drop it into the record at the moment the user begins to add the new
record.

Something like this:

Private Sub Form_BeforeInsert(Cancel As Integer)
Dim varResult As Variant
varResult = DMax("MyDate", "MyTable)
If Not IsNull(varResult) Then
Me.MyDate = varResult + 1
End If
End Sub
 
Thanks for your help.

Keith


Allen Browne said:
Use the BeforeInsert event procedure of the form. It will lookup the date
and drop it into the record at the moment the user begins to add the new
record.

Something like this:

Private Sub Form_BeforeInsert(Cancel As Integer)
Dim varResult As Variant
varResult = DMax("MyDate", "MyTable)
If Not IsNull(varResult) Then
Me.MyDate = varResult + 1
End If
End Sub
 
Back
Top