Command button to insert date into field

  • Thread starter Thread starter Mark Annand
  • Start date Start date
M

Mark Annand

Guest
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?
 
Put this code in the button:

textbox.value = date()


Cody
 
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.
 
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
 
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.
 
Thanks to both of you. That works now ... even on the 29th!

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

Best wishes

Mark
 

Users who are viewing this thread

Back
Top Bottom