ActiveX Ctrl -- Calendar

I added the Calendar object to a form.    When clicking on a ComboBox (DocumentDate), I bring up the calendar and can select a date.

I now have moved the ComboBox ctrl to a tab/page... so far so good.

However, on a second tab/page, I want to call the calendar via a 2nd date combo.   I want the calendar to be positioned at different X/Y coordinates.  So, I ended up inserting a 2nd Calendar control to the 2nd tab.   I also renamed it from "Calendar" to "Calendar2".  

Unfortunately, above does not work (I guess it doesn't recognize "Calendar2").

Okay, I now added the calendar to a stand-alone form that I want to call from either one of the two date combos.  I named the form the calendar resides on "frmCalendar".

Below are 2 sets of functions
1. "OriginalFunctions" (between ===s)
2. "ChangedFunctions" (between ***s)

I get an error though via the "ChangedFunctions" approach.  

So, here is my question... does anyone know how I can call the calendar (frmCalendar) from either date combo on either worksheet (different X/Y coordinates)?


Thanks,
Tom




======= OriginalFunctions=============
Private Sub DocumentDate_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

  ' Show Calendar and set its date.
   Calendar.Visible = True
   Calendar.SetFocus
   ' Set to today if DocumentDate has no value.
   Calendar.Value = IIf(IsNull(DocumentDate), Date, DocumentDate.Value)

End Sub

Private Sub Calendar_Click()
   ' Set OrderDate to the selected date and hide the calendar.
   DocumentDate.Value = Calendar.Value
   DocumentDate.SetFocus
   Calendar.Visible = False

End Sub
======= OriginalFunctions=============


******* ChangedFunctions*************
Private Sub DocumentDate_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

  ' Show Calendar and set its date.
   Forms![frmCalendar].[Calendar].Visible = True
   Forms![frmCalendar].[Calendar].SetFocus
   ' Set to today if DocumentDate has no value.
   Forms![frmCalendar].[Calendar].Value = IIf(IsNull(DocumentDate), Date, DocumentDate.Value)

End Sub

Private Sub Calendar_Click()
   ' Set OrderDate to the selected date and hide the calendar.
   DocumentDate.Value = Forms![frmCalendar].[Calendar].Value
   DocumentDate.SetFocus
   Forms![frmCalendar].[Calendar].Visible = False

End Sub
******* ChangedFunctions*************
TomBock2004Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

peter57rCommented:
Hello TomBock2004,

I assume you are using an Openform satament to display the calendar and that you have different openform statements for each combo.
In the Openform statement the last argument is OpenArgs.  You can use this to pass data/info to the form you are opening.
You could put a value ther which tells the calandar form wher it is being called from.  In the calendar form Open event procedure you can test the value of Openargs and then use whatever positioning code you like (movesize or whatever) to position the form.

if me.openargs = 1 then
docmd.movesize 1000, 2000
else
docmd.movesize 2000, 5000
end if


Pete
0
MourdekaiCommented:
This example database will show you how to open a form relative to a control.

http://www.lebans.com/openform.htm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TomBock2004Author Commented:
Mourdekai:

Thanks for the link to Stephen's site... the sample works great.

However, I have some difficulties combining his solution with my attempt to utilize the calendar (which sits on the called form).

As listed in the original function, when clicking on the combo, the calendar would pop up, I then select a date, and in turn the combo's date is updated.

Now, I have changed the function to accomodate Stephen's approach.   The form pops up fine but when I click on a date the on "frmCalendar", the date combo on "frmCorrespondence" does not change at all.  

Do you have any suggestions as to how I pass on the selected value from the frmCalendar to frmCorrespondence?

Here are the 2 functions:


*******************************************

Private Sub DocumentDate_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)

    Dim blRet As Boolean
    blRet = PositionFormRelativeToControl("frmCalendar", Forms![frmCorrespondence].[DocumentDate], 2)

    Forms![frmCalendar].[Calendar].Value = IIf(IsNull(Forms![frmCorrespondence].[DocumentDate]), Date, Forms![frmCorrespondence].[DocumentDate].Value)
   
End Sub

*******************************************

Private Sub Calendar_Click()

   DocumentDate.Value = Forms![frmCalendar].[Calendar].Value
   DocumentDate.SetFocus
   Forms![frmCalendar].[Calendar].Visible = False

End Sub

*******************************************

0
TomBock2004Author Commented:
Raised the points to 500...

Tom
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.