Can an activeX controle calender holds date of today

P

Peter Adema

I created an activeX control (calender control 9.0)in a
form.
You can set a default date in this calender.

I want Access to fill in automatically the current date.
How can I do this?
 
N

Nikos Yannacopoulos

Pete,

It takes one line of code to do this, whether you want today's date
defaulted in on all records, or just new ones (that is, if the control is
bound to a table field, in which case you don't want to change existing
dates).
In either case, the code goes to the form's On Current event.
For all records:

Me.ActiveXCtl0 = Date

For new records only:

If Me.NewRecord Then Me.ActiveXCtl0 = Date

Just change ActiveXCtl0 to the actual name of your calendar control.

To paste the code where it belongs: while in form design view, select the
calendar control, display the properties window, select tab Events and put
the cursor next to On Current; click on the little button with the three
dots on the right, and select Code Builder; you will be taken to a VB editor
screen, and the cursor will be between these lines:

Private Sub Form_Current()

End Sub

Just paste the line of code in between, and close the VB window. The trick
is done.

HTH,
Nikos
 

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

Similar Threads

changing the date in a calender control. 5
open a calender with vbscript 1
Calender Control on a Form 2
calender combo box 2
Calender of Jobs 14
ENTER A DATE USING CALENDAR CONTROL 2
Calender 1
Calender Activex Help 1

Top