Auto Date Insertion

  • Thread starter Thread starter Neil Warwick
  • Start date Start date
N

Neil Warwick

I have a form which needs to insert certain information
into various fields when the form opens, most of them seem
to work ok, except the one to insert the current date ina
specific field.
I have used the code below, but get an error message.

Private Sub Form_Open(Cancel As Integer)
Dim todaysDate As Date
todaysDate = Date
Me.Date1.Text = todaysDate
End Sub

Looking at various books and help files I think it should
work, but I get the message:

Runtime Error 94
Invalid use of null

Some of the texts that I've looked at suggest that I need
to have () after the use of Date on the 3rd line, but when
I add these the VBA editor removes them!

Thanks in advance to the saviour of my sanity

Neil
 
Neil,

Just drop the referenece to the control's Text property. A reference like:

Me.Date1 = todaysDate

will do the trick.

HTH,
Nikos
 
Back
Top