Discussion Locked

MS Access 2000 Command Buttons

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
How can I creat a command button to open and activex control such as calendar to enter a date in a date/time field?

1 reply

by shmaltz

I had the same problem the following is what I did.
I created a form (FrmClndr) with the dialog and popup properties set to true, and the whole form consisted of a calendar control. Created a text box that holds the date, a command button that calls FrmClndr. When the command button was clicked it also passed the current value (which was set as default on the textbox to today, you could however play around and set the default to whatever you want) of the textbox that holds the date as an open argument, and set the value of the calendar control to the openarg value (using cdate function, since the openarguments is of Text datatype). Now I don't remember how I ended up doing the rest, it was either of the following:
When the user clicked the OK button on the FrmClndr the value of the calendar control was passed to the previous forms textbox that holds the date, Since I don't remember if this is possible when you have a popup/dialog open I don't know if it worked. If this doesn't work I did the follwing (I remember playing around with both I don't however remember which one worked). On the previous form I created a static variable on the form level to accept the change of the date value and passed it on to the text box once the previous form recieved the focus back from FrmClndr. If you go this way you have to make sure that this staic variable is always set by the FrmClndr even when the user clicks cancel on FrmClndr, otherwise you will get a runtime error if the veriable isstill null/empty.
I hope this helps email if you have any questions. I assume you know VBA.

This discussion is closed to new replies.