473,895 Members | 2,245 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.visibl ed = true
calendar1.day =
calendar1.month =
calendar1.year =

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

thanks all
Jing.
Nov 13 '05 #1
3 3447
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![YourTextBoxCont rol]

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

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

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

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_****@NOSPAMy ahoo.com> wrote in message
news:1j******** ***********@new s20.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.visibl ed = 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.Visib le = Not Calendar1.Visib le
d = CDate(txtCalend ar.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************ ****@telusplane t.net> wrote in message
news:s62Gc.5044 4$l6.46894@clgr ps12...
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![YourTextBoxCont rol]

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

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

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

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_****@NOSPAMy ahoo.com> wrote in message
news:1j******** ***********@new s20.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.visibl ed = 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_****@NOSPAMy ahoo.com> wrote in message
news:tO******** ***********@new s20.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.Visib le = Not Calendar1.Visib le
d = CDate(txtCalend ar.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
3887
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
3436
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 current date instead? Note: it does this fine if I'm using it in the context of a form's text box, but I'm trying to use it on a module which is called, whereby the date chosen is the date plugged into a variable. Everytime after I reset the...
7
2762
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 searched this forum high and low to find a solution and have tried virtually everything mentioned, all to no avail. Some solutions even crash the computer. Does anyone have any ideas? Thanks TD
3
1902
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 (ASP Classic), I would have used three comboboxes for the date, one for the day, one for the month and one for the year. I'm sure ASP.NET has a better way of doing it. I have seen the calendar control, but all the examples I have seen involve a...
9
3056
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 do this? Thanks Devron
0
1315
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 have reports. Is there some way that I can highlight certain days?
6
12569
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 calendar control to allow my users to enter a date but I need them to enter a time as well. It doesn't look like the calendar control will allow times to be entered so I was thinking of having two text boxes. One text box would contain the date...
1
1369
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
1924
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 “date” field. It is a similar idea to what you see on travel websites when booking trips. Any ideas. Thanks Denis
0
9990
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9835
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11249
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10473
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9649
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8028
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7177
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5863
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6068
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.