How do I create a button in Access that, when clicked, automatica.

J

Jsimmons823

I would like to make a command button, actually 3 beside a field, that when I
click the button, it automatically inserts today's date into the field beside
it. I am stuck when it comes to that and I would like to know. Thank You
 
L

Lynn Trapp

Add the following code, with appropriate names, in the Click event of your
button.

Me.txtYourTextField = Date()
 
J

John Vinson

I would like to make a command button, actually 3 beside a field, that when I
click the button, it automatically inserts today's date into the field beside
it. I am stuck when it comes to that and I would like to know. Thank You

Put the following code into the button's Click event. Click the ...
icon by the Click property on the Events tab in the command button's
properties, and invoke the Code Builder:

Private Sub cmdDate1_Click()
Me!txtDate1 = Date
End Sub

Perhaps even easier (though it involves some user training) is to put
the same line of code in txtDate1's DoubleClick event; the user can
simply doubleclick in the textbox to get today's date entered. Easier
yet (on you, not the user) - teach them that ctrl-; will enter the
date automatically.


John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top