One Calendar form for different fields

G

Guest

Can I just use one form with a calendar on it for all date fields on all of
my forms instead of many calendar forms with a control source for each field?
I thought I could change the control source with the OnClick property of a
button next to each date field I want to use but I haven't had success.
Thanks
 
G

Guest

thanks for the examples, but I was really just looking to assign the calendar
control source to a variable so I could write the value into different fields
using code on a buton click() property...
 
S

Steve

I put a calendar named Calendar on a popup form named PFrmCalendar. Put the
following code in the Open event of the popup form:
Me.Caption = Me.OpenArgs
Put the following code in the AfterUpdate event of the calendar:
Me.Visible = False
Add a button captioned Cancel and put the following code in the Click event:
DoCmd.Close

Add a textbox named MyDate to your form for the date field. Go to Properties
and the Data tab and lock the textbox. Add a button next to the textbox,
make the caption "Enter Date" and put the following code in the click event:
DoCmd.OpenForm "PFrmCalendar",,,,acDialog,"Whatever You Want For The Caption
Of The Calendar Form"
If SysCmd(acSysCmdGetObjectState, acForm, "PFrmCalendar") <> 0 Then
Me!MyDate = Forms!PFrmCalendar!Calendar.Value
DoCmd.Close "PFrmCalendar"
End If

You can do the same as above for multiple date fields on a form or for date
fields on multiple forms.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
G

Guest

Hey Steve, thanks for clueing me in! In spite of what some have said, I find
many of your responses to be quite informative.
 
G

Guest

thanks for the responses...I tried various things and what seems to be
working for now is to leave the calendar control source blank in properties
and then in the OnClick() event of the command button, open the calendar form
and add the following

Forms!Calendar.Form!ActiveXCtl0.ControlSource = "end_date"

where 'Calendar' is the form name, 'ActiveXCtl0' is the name of the calendar
control, and "end_date" is the field to write the selected date from the
calendar...just change the line for each command button to the field name you
wish to use as the source...
 

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