Link calendar to text box field?

C

Cam

Hello,

I am designing a form for user data entry and have a date field which I have
current date as default, but if user need to input data from another date, I
want the following to happened.

1) user click on the date field and pop up a calendar so they can select a
date
2) Date field change to the date from the calendar input.
3) once user move to the next field, hide the calendar.

Is this possible? and how and what is the vba code to design this? Thanks
 
L

Linq Adams via AccessMonster.com

What I do for this type of thing is place a calendar control on the form,
positioned as you like and set it's Visible Property to NO. This hack was
written to be used with an ActiveX calendar control, but should work with a
third-party calendar, such as Allen Browne's or Tony Toews.

Then, using the DoubleClick property of your text box, have the calendar
"popup" for date selection. You'll need to replace YourCalendarName and
YourTextBoxName with the actual names of your calendar and text box.

Private Sub Form_Load()
YourCalendarName.Value = Date
End Sub

Private Sub YourTextBoxName_DblClick(Cancel As Integer)
YourCalendarName.Visible = True
End Sub

Private Sub YourCalendarName_Click()
Screen.PreviousControl = YourCalendarName.Value
YourTextBoxName.SetFocus
YourCalendarName.Visible = False
End Sub

Now, all your user has to do is DoubleClick on the text box and up pops the
calendar! When the user clicks on the date, the calendar disappears and the
text box is populated with the date.
 

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