View Full Version : Command button to insert date into field


Mark Annand
02-28-2000, 07:30 AM
I have a form and I'd like to add a button that inserts the current date into a particular field, overwriting the contents of the field ... how possible is this with Access 97?

cstaab
02-28-2000, 08:59 AM
Put this code in the button:

textbox.value = date()


Cody

Mark Annand
02-29-2000, 03:08 AM
Er, I'm very new to this. Adding that to the button results in the error message 'Microsoft Access can't find the macro 'textbox'' or whatever ... need a bit more help with this.

KDg
02-29-2000, 04:54 AM
you need to change textbox to whatever the name of your text box is. eg if it's called txtDate then you would have

me!txtDate.value=Date
if it's called Text0 then the code will be me!Text0.value=Date

and so on - you need to check the name in properties,

HTH

cstaab
02-29-2000, 06:33 AM
In design view, right click on the button and select properties. Click on the events tab. Click in the on-click event area. Click the elippse (...) and choose code builder. Put the code within this macro.

Mark Annand
02-29-2000, 07:35 AM
Thanks to both of you. That works now ... even on the 29th!

Private Sub Command120_Click()
Lastattended.Value = Date
End Sub

Best wishes

Mark