472,328 Members | 1,083 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 software developers and data experts.

Highlight the date on the calendar control

Hi all,

I have a masked text control that would return a date in string format via
the mask property like:

"9/23/2004"

and i have a calendar control that would pop up when I click a command
button, I know the masked text control always returns a valid date. How do I
code in the command click to highlight the correct date on calendar control?
Which date functions do I need, if I need any at all?

for example:
'--------------------------------------
private sub command1_click()
calendar.visibled = true
calendar1.day =
calendar1.month =
calendar1.year =

End Sub
'--------------------------------------

thanks all
Jing.
Nov 13 '05 #1
3 3332
Hi Jing,

Assuming that the calendar is the default ActiveX calendar control that
ships with Access...
Try this code (tested and working ... but you'll have to edit control names
to match your controls of course)

****************************
Private Sub Command1_Click()

Dim varDate
varDate = Me![YourTextBoxControl]

If IsDate(varDate) Then
Me![YourCalendarControl].Visible = True
Me![YourCalendarControl].Value = varDate
Me.Refresh
Else
Me![YourCalendarControl].Visible = False
MsgBox ("You must enter a valid date in YourTextBoxControl.")
Me![YourTextBoxControl] = "" 'This line is optional ... clears the
incorrect entry.
Me![YourTextBoxControl].SetFocus
End If

End Sub
****************************

--
HTH,
Don
=============================
E-Mail (if you must)
My*****@Telus.net

Disclaimer:
Professional PartsPerson
Amateur Database Programmer {:o)

I'm an Access97 user, so all posted code
samples are also Access97- based
unless otherwise noted.

Do Until SinksIn = True
File/Save, <slam fingers in desk drawer>
Loop

================================

"JingleBEV" <n_****@NOSPAMyahoo.com> wrote in message
news:1j*******************@news20.bellglobal.com.. .
Hi all,

I have a masked text control that would return a date in string format via
the mask property like:

"9/23/2004"

and i have a calendar control that would pop up when I click a command
button, I know the masked text control always returns a valid date. How do I code in the command click to highlight the correct date on calendar control? Which date functions do I need, if I need any at all?

for example:
'--------------------------------------
private sub command1_click()
calendar.visibled = true
calendar1.day =
calendar1.month =
calendar1.year =

End Sub
'--------------------------------------

thanks all
Jing.

Nov 13 '05 #2
Don,
Thanks for the quick response. I figured it out and it works, the code looks
like this:
'***************************
Private Sub Command1_Click()
Dim d As Date
Calendar1.Visible = Not Calendar1.Visible
d = CDate(txtCalendar.Mask)
Calendar1.Day = DatePart("d", d)
Calendar1.Month = DatePart("m", d)
Calendar1.Year = DatePart("yyyy", d)
End Sub
'*************************************
I already know that it's a valid date, because it's generated by the
calendar control.

"Don Leverton" <le****************@telusplanet.net> wrote in message
news:s62Gc.50444$l6.46894@clgrps12...
Hi Jing,

Assuming that the calendar is the default ActiveX calendar control that
ships with Access...
Try this code (tested and working ... but you'll have to edit control names to match your controls of course)

****************************
Private Sub Command1_Click()

Dim varDate
varDate = Me![YourTextBoxControl]

If IsDate(varDate) Then
Me![YourCalendarControl].Visible = True
Me![YourCalendarControl].Value = varDate
Me.Refresh
Else
Me![YourCalendarControl].Visible = False
MsgBox ("You must enter a valid date in YourTextBoxControl.")
Me![YourTextBoxControl] = "" 'This line is optional ... clears the
incorrect entry.
Me![YourTextBoxControl].SetFocus
End If

End Sub
****************************

--
HTH,
Don
=============================
E-Mail (if you must)
My*****@Telus.net

Disclaimer:
Professional PartsPerson
Amateur Database Programmer {:o)

I'm an Access97 user, so all posted code
samples are also Access97- based
unless otherwise noted.

Do Until SinksIn = True
File/Save, <slam fingers in desk drawer>
Loop

================================

"JingleBEV" <n_****@NOSPAMyahoo.com> wrote in message
news:1j*******************@news20.bellglobal.com.. .
Hi all,

I have a masked text control that would return a date in string format via the mask property like:

"9/23/2004"

and i have a calendar control that would pop up when I click a command
button, I know the masked text control always returns a valid date. How
do I
code in the command click to highlight the correct date on calendar

control?
Which date functions do I need, if I need any at all?

for example:
'--------------------------------------
private sub command1_click()
calendar.visibled = true
calendar1.day =
calendar1.month =
calendar1.year =

End Sub
'--------------------------------------

thanks all
Jing.


Nov 13 '05 #3
Hi "JingleBEV",

I'm confused...

Are you telling me that you:
----------------------------
1.) Select a date on the calendar which inserts the selected date value into
a textbox? (Is this a bound or unbound textbox? ... It sounds like a bound
field to me, now.)
2.) Then you use the command button to toggle the calendar's .Visible
Property? If it *is* visible when you click the button, it becomes
invisible, and vise-versa? If so, that seems bizarre to me ... why would you
want to do that?
3.) Next you use the date that you just inserted into the textbox to
"highlight" a date on your calendar?

If this textbox is a bound control, I'd suggest doing it this way:
-------------------------------------------------------------
1.) Test its value using the IsDate() function in the form's On Current
event.
2.) If it contains a valid date value, then assign the calendars .Value
property to the value in the textbox, which has the same effect as setting
your .Day, .Month, .Year properties as you have done below.
3.) This "test" could also be used to determine the calendar's .Visible
property. If it contains a valid date, display the calendar... if not, then
hide the calendar.

Don
"JingleBEV" <n_****@NOSPAMyahoo.com> wrote in message
news:tO*******************@news20.bellglobal.com.. .
Don,
Thanks for the quick response. I figured it out and it works, the code looks like this:
'***************************
Private Sub Command1_Click()
Dim d As Date
Calendar1.Visible = Not Calendar1.Visible
d = CDate(txtCalendar.Mask)
Calendar1.Day = DatePart("d", d)
Calendar1.Month = DatePart("m", d)
Calendar1.Year = DatePart("yyyy", d)
End Sub
'*************************************
I already know that it's a valid date, because it's generated by the
calendar control.

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: kvrdev1 | last post by:
What reference do I need to add in to be able to use a date drop-down control within my web application? Thank you! -Valerie
5
by: Larry R Harrison Jr | last post by:
I use the Lebans calendar control and love it; the only thing is that it commonly starts out at the year 1899 rather than the current year. Is there...
7
by: TDIOwa | last post by:
I have a form that has a specific date on it. I want to open another form that has the Active Control Calendar on it. I want to open this form to...
3
by: Alan Silver | last post by:
Hello, I have an app where the user needs to fill in details about an event, including the date and time of the event. I want a clean way to...
9
by: Devron Blatchford | last post by:
Hi there, Just wondering if I change the back and fore colour of a listview item when the mouse hovers over it? I want to overide the default...
0
by: tomcarr1 | last post by:
I want to use the calendar control so that the user can click on a date and see a report for that date. However, there are not reports for every...
6
by: Luvin lunch | last post by:
Hi, I'm new to access and am very wary of dates as I have limited experience in their manipulation and I know if they're not done properly...
1
by: SNY | last post by:
How to highlight the number of dates in a calendar?The number of days which has to be selected is mentioned in the Start date and End date in 2...
3
by: Denis | last post by:
I have a field called date . I want to have a drop down box which, when you chick on it, will show a calendar. Upon selecting a date from this...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.