Solved Trigger a control's datepicker with a separate button (1 Viewer)

Richard Horne

Member
Local time
Today, 15:46
Joined
Oct 15, 2020
Messages
55
Is it possible to have a control - formatted as a date - have its datepicker popup when a separate button is pressed?

Basically I want to put a date field on a form with a calendar icon next to it. When the calendar icon/button is clicked I want the datepicker to appear.

I know you can just click into the date field and the datepicker will popup automatically but I've been asked to build the form this specific way if possible.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:46
Joined
May 7, 2009
Messages
19,175
you can have a Command button on the form.
on the Click event you add this code:
Code:
Private Sub Command1_Click()
Me![theDateTextbox].SetFocus
DoCmd.RunCommand acCmdShowDatePicker
End Sub
 

moke123

AWF VIP
Local time
Today, 11:46
Joined
Jan 11, 2013
Messages
3,852
Better yet, you can make your own date picker.

 

Richard Horne

Member
Local time
Today, 15:46
Joined
Oct 15, 2020
Messages
55
you can have a Command button on the form.
on the Click event you add this code:
Code:
Private Sub Command1_Click()
Me![theDateTextbox].SetFocus
DoCmd.RunCommand acCmdShowDatePicker
End Sub

Oh as simple as that. I'd already set focus, didn't realise that's all I needed to do.

Thanks arnelgp :D
 

Users who are viewing this thread

Top Bottom