date

  • Thread starter Thread starter tony wong
  • Start date Start date
T

tony wong

how come there is no auto input by the following code.

***************
Private Sub XYZitem_AfterUpdate()

Me.XYZfrm = Date

End Sub
****************

however, when i change as following, it works.

Me.XYZfrm = "2004/9/20"

i run "? date" in the immediately windows, the answer is 2004/9/20

Therefore, what is wrong with me? Thanks.
 
Tony-

First, you are using a reserved word- "DATE"

Second, you have not assigned a value to DATE.

Consider the following changes:

If you want current date:

Private Sub XYZitem_AfterUpdate()

Me.XYZfrm = Format(Now(),"mm/dd/yyyy")

End Sub

If you want user to input date:

Sub GetDate()

dim theDate as Date

theDate=InputBox("EnterDate","Date Entry",Now())

Me.XYZfrm=theDate

'Or one line- Me.XYZfrm=InputBox("EnterDate","Date
Entry",Now())


Regards

Bernie
****************
 
Back
Top