Working with pop-up calendars for date fields on forms

H

hfreedman

I am currently using the following subroutines to allow a pop-up calendar
(ActiveXCalendar) to appear to select the date for the date fields on my
form. If I have more than one date field, I include an addtional copy of the
ActiveXCalendar and of the routines with unique names of course. I now have a
form with about 15 date fields. Is there a way I can alter these routines so
one ActiveXCalendar and one set of routines can be used to pop up the
calendar and assign the selected date to whichever date field is in focus and
is clicked on? One additional feature I would like is the ability to press
esc to close the pop-up calendar without assigning a date to field. Currently
you must select a date to close the pop-up.

Private Sub ActiveXCalendar_Click()
[Target Delivery Date].Value = ActiveXCalendar.Value
[Target Delivery Date].SetFocus
ActiveXCalendar.Visible = False
End Sub

Private Sub Form_Current()
ActiveXCalendar.Visible = False
End Sub
 
W

Wayne-I-M

Hi

Here is just a very basic idea for you 15 time fields

Create a new form
Put a button on it called SomeButtonName
Put and calender on it called ActiveXCalendar
put a few text boxes on it called TextBox1 TextBox2 TextBox3 TextBox4

Open the code window and paste this

Private Sub SomeButtonName_Click()
If Me.ActiveXCalendar.Visible = True Then
Me.ActiveXCalendar.Visible = False
Else
If Me.ActiveXCalendar.Visible = False Then
Me.ActiveXCalendar.Visible = True
End If
End If
End Sub
Private Sub TextBox1_Click()
If Me.ActiveXCalendar.Visible = True Then
Me.TextBox1 = ActiveXCalendar.Value
End If
End Sub
Private Sub TextBox2_Click()
If Me.ActiveXCalendar.Visible = True Then
Me.TextBox2 = ActiveXCalendar.Value
End If
End Sub
Private Sub TextBox3_Click()
If Me.ActiveXCalendar.Visible = True Then
Me.TextBox3 = ActiveXCalendar.Value
End If
End Sub
Private Sub TextBox4_Click()
If Me.ActiveXCalendar.Visible = True Then
Me.TextBox4 = ActiveXCalendar.Value
End If
End Sub



You'll see the idea - as I said "very" simple :) you could always declare
the textbox name as a variable and use this is this button click - but I have
kept in "really" simple so you get the general idea.

You only need one calendar
 
H

hfreedman

Hi Chris,
This solution is PERFECT!!!! Thanks so very much. I will be using it
religiously in all future applications.

vbasean said:
I really like this solution:
http://www.everythingaccess.com/tutorials.asp?ID=Popup-Calendar

--
~Your Friend Chris
http://myvbastuff.blogspot.com/
thinking out loud


hfreedman said:
I am currently using the following subroutines to allow a pop-up calendar
(ActiveXCalendar) to appear to select the date for the date fields on my
form. If I have more than one date field, I include an addtional copy of the
ActiveXCalendar and of the routines with unique names of course. I now have a
form with about 15 date fields. Is there a way I can alter these routines so
one ActiveXCalendar and one set of routines can be used to pop up the
calendar and assign the selected date to whichever date field is in focus and
is clicked on? One additional feature I would like is the ability to press
esc to close the pop-up calendar without assigning a date to field. Currently
you must select a date to close the pop-up.

Private Sub ActiveXCalendar_Click()
[Target Delivery Date].Value = ActiveXCalendar.Value
[Target Delivery Date].SetFocus
ActiveXCalendar.Visible = False
End Sub

Private Sub Form_Current()
ActiveXCalendar.Visible = False
End Sub
 
H

hfreedman

Thanks Wayne. Much appreciated. Chris's solution is very simple and elegant.
I'm going with that. Thanks anyway.

Wayne-I-M said:
Hi

Here is just a very basic idea for you 15 time fields

Create a new form
Put a button on it called SomeButtonName
Put and calender on it called ActiveXCalendar
put a few text boxes on it called TextBox1 TextBox2 TextBox3 TextBox4

Open the code window and paste this

Private Sub SomeButtonName_Click()
If Me.ActiveXCalendar.Visible = True Then
Me.ActiveXCalendar.Visible = False
Else
If Me.ActiveXCalendar.Visible = False Then
Me.ActiveXCalendar.Visible = True
End If
End If
End Sub
Private Sub TextBox1_Click()
If Me.ActiveXCalendar.Visible = True Then
Me.TextBox1 = ActiveXCalendar.Value
End If
End Sub
Private Sub TextBox2_Click()
If Me.ActiveXCalendar.Visible = True Then
Me.TextBox2 = ActiveXCalendar.Value
End If
End Sub
Private Sub TextBox3_Click()
If Me.ActiveXCalendar.Visible = True Then
Me.TextBox3 = ActiveXCalendar.Value
End If
End Sub
Private Sub TextBox4_Click()
If Me.ActiveXCalendar.Visible = True Then
Me.TextBox4 = ActiveXCalendar.Value
End If
End Sub



You'll see the idea - as I said "very" simple :) you could always declare
the textbox name as a variable and use this is this button click - but I have
kept in "really" simple so you get the general idea.

You only need one calendar


--
Wayne
Manchester, England.



hfreedman said:
I am currently using the following subroutines to allow a pop-up calendar
(ActiveXCalendar) to appear to select the date for the date fields on my
form. If I have more than one date field, I include an addtional copy of the
ActiveXCalendar and of the routines with unique names of course. I now have a
form with about 15 date fields. Is there a way I can alter these routines so
one ActiveXCalendar and one set of routines can be used to pop up the
calendar and assign the selected date to whichever date field is in focus and
is clicked on? One additional feature I would like is the ability to press
esc to close the pop-up calendar without assigning a date to field. Currently
you must select a date to close the pop-up.

Private Sub ActiveXCalendar_Click()
[Target Delivery Date].Value = ActiveXCalendar.Value
[Target Delivery Date].SetFocus
ActiveXCalendar.Visible = False
End Sub

Private Sub Form_Current()
ActiveXCalendar.Visible = False
End Sub
 
W

Wayne-I-M

If you have 15 date controls on your form. My 5 mins form is better.

Just create the form as I said (just of a test if nothing else).
Click to show the calendar
Click any or all of the text boxes and the date is inserted.

Up to you


--
Wayne
Manchester, England.



hfreedman said:
Thanks Wayne. Much appreciated. Chris's solution is very simple and elegant.
I'm going with that. Thanks anyway.

Wayne-I-M said:
Hi

Here is just a very basic idea for you 15 time fields

Create a new form
Put a button on it called SomeButtonName
Put and calender on it called ActiveXCalendar
put a few text boxes on it called TextBox1 TextBox2 TextBox3 TextBox4

Open the code window and paste this

Private Sub SomeButtonName_Click()
If Me.ActiveXCalendar.Visible = True Then
Me.ActiveXCalendar.Visible = False
Else
If Me.ActiveXCalendar.Visible = False Then
Me.ActiveXCalendar.Visible = True
End If
End If
End Sub
Private Sub TextBox1_Click()
If Me.ActiveXCalendar.Visible = True Then
Me.TextBox1 = ActiveXCalendar.Value
End If
End Sub
Private Sub TextBox2_Click()
If Me.ActiveXCalendar.Visible = True Then
Me.TextBox2 = ActiveXCalendar.Value
End If
End Sub
Private Sub TextBox3_Click()
If Me.ActiveXCalendar.Visible = True Then
Me.TextBox3 = ActiveXCalendar.Value
End If
End Sub
Private Sub TextBox4_Click()
If Me.ActiveXCalendar.Visible = True Then
Me.TextBox4 = ActiveXCalendar.Value
End If
End Sub



You'll see the idea - as I said "very" simple :) you could always declare
the textbox name as a variable and use this is this button click - but I have
kept in "really" simple so you get the general idea.

You only need one calendar


--
Wayne
Manchester, England.



hfreedman said:
I am currently using the following subroutines to allow a pop-up calendar
(ActiveXCalendar) to appear to select the date for the date fields on my
form. If I have more than one date field, I include an addtional copy of the
ActiveXCalendar and of the routines with unique names of course. I now have a
form with about 15 date fields. Is there a way I can alter these routines so
one ActiveXCalendar and one set of routines can be used to pop up the
calendar and assign the selected date to whichever date field is in focus and
is clicked on? One additional feature I would like is the ability to press
esc to close the pop-up calendar without assigning a date to field. Currently
you must select a date to close the pop-up.

Private Sub ActiveXCalendar_Click()
[Target Delivery Date].Value = ActiveXCalendar.Value
[Target Delivery Date].SetFocus
ActiveXCalendar.Visible = False
End Sub

Private Sub Form_Current()
ActiveXCalendar.Visible = False
End Sub
 
T

Tony Toews [MVP]

hfreedman said:
I now have a
form with about 15 date fields.

Why do you have so many date fields? Should each of those be in a
child table? What happens when the user requires 16 date fields?

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
B

big osborne

Tony Toews said:
Why do you have so many date fields? Should each of those be in a
child table? What happens when the user requires 16 date fields?

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 

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