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

richardhorne

New member
Local time
Today, 22:23
Joined
Oct 15, 2020
Messages
27
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
Tomorrow, 05:23
Joined
May 7, 2009
Messages
16,129
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, 17:23
Joined
Jan 11, 2013
Messages
2,802
Better yet, you can make your own date picker.

 

richardhorne

New member
Local time
Today, 22:23
Joined
Oct 15, 2020
Messages
27
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