473,320 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 3414
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 a way to specifically tell it to start at the...
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 the specific date on the first form. I have...
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 allow them to pick the date and time. In the old days...
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 windows colour. Can someone please tell me how to...
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 day, so I would like to highlight the days that...
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 things can turn ugly quickly. I would like to use a...
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 Textboxes.
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 calendar it will put the selected date in the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.