[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

ActiveX Ctrl -- Calendar

Posted on 2004-10-21
4
Medium Priority
?
341 Views
Last Modified: 2012-08-13
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*************
0
Comment
Question by:TomBock2004
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 12378803
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
 
LVL 8

Accepted Solution

by:
Mourdekai earned 2000 total points
ID: 12385769
This example database will show you how to open a form relative to a control.

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

Author Comment

by:TomBock2004
ID: 12388217
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
 

Author Comment

by:TomBock2004
ID: 12388222
Raised the points to 500...

Tom
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question