Calendar NewMonth() - get month value

G

Gil D.

Hello,

I have a Calendar control in my form.
I have a subform which displays records for Calendar chosen month.

My problem:
I want to read calendar month value when the user selects new month
(before day select).
I used Calendar_NewMonth() event, but I can not get correct month value
with Calendar.month property.

How can I do this ?

Thank you
Gil D.
 
P

PC Datasheet

The calendar has an update event. Use this expression:
Dim CorrectMonth As Integer
CorrectMonth = Month(Me!NameOfCalendarControl.Value)

CorrectMonth will be the month number. For month name use:
Dim CorrectMonth As String
CorrectMonth = Format(Month(Me!NameOfCalendarControl.Value),"mmmm")


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com

If you can't get the help you need in the newsgroup, I can help you for a
very reasonable fee. Over 1000 Access users have come to me for help.
Need a month calendar or 7 day calendar? Need appointment scheduling? Need
room reservations scheduling? Need employee work scheduling? Contact me!
 
G

Gil D.

Hello,

Thank you for your answer.
I am using access 97 and the OnUpdate() event does not work
(Is this an access 97 known bug ?)
Is there a different way to do this ?

Thank you
Gil D.
 
N

Newbee Here

PC Datasheet said:
If you can't get the help you need in the newsgroup, I can help you for a
very reasonable fee. Over 1000 Access users have come to me for help.
Need a month calendar or 7 day calendar? Need appointment scheduling? Need
room reservations scheduling? Need employee work scheduling? Contact me!

These 1000 (if at all a real figure..) is only the result of
-- 4 years abusing the newsgroups.
-- 4 years blatantly advertising and job hunting.

You only care about making money, and you act as if the groups are your private hunting ground.
So why would ANYBODY ever trust a person like you and hire you?
********************************************************

Explanation and more on this answer to Steve:
http://home.tiscali.nl/arracom/stopsteve.html

Arno R
 
P

PC Datasheet

It doesn't appear there's an event to do that. Explain why you need the
month and maybe we can come up with some alternative logic.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com

If you can't get the help you need in the newsgroup, I can help you for a
very reasonable fee. Over 1000 Access users have come to me for help.
Need a month calendar or 7 day calendar? Need appointment scheduling? Need
room reservations scheduling? Need employee work scheduling? Contact me!
 
G

Gil D.

Hello,

I have a form which displays worker's personal details.
I have a subform which displays working hours.

I have a calendar control in my form.

My subform should display current month records,
so I need to requery it when the user selects a month in the calendar
control (before he selects a specific day).

Thank you
Gil D.
 
P

PC Datasheet

I couldn't find a way to return the month when you change it in the combobox
so maybe this will work for you ---

You used "Calendar" as the name of your control so I will do the same.
1. Go to Calendar in design view, open properties and set
ShowDateSelections and ShowTitle to No. This will reduce the top border of
the calendar control.
2. The Year combobox in the calendar control contains the years 1900 to
2100. Create a table with the numbers from 1900 to 2100 then create a
combobox named CbxYear based on this table. Position the year combobox just
above the calendar control.
3. Create a new month combobox named CbxMonth and use a value list for the
rowsource. The value list must look like:
1,Jan;2,Feb;3,Mar etc. Note the comma after the number and semi-colon after
the month. Set the BoundColumn property to 1, ColumnCount to 2 and
ColumnWidth to 0;.75. Position this combobox directly above the calendar
control.
4. Create a label named LblMonthYear wide enough to hold "September 2005"
and position the label just above the calendar control.
5. Your calendar control should now almost look like the original calendar
control.
6. Put the following code in the Open event of your form that contains the
calendar:
Me!CbxMonth = Month(Date())
Me!CbxYear = Year(Date()
Me!LblMonthYear.Caption = Me!CbxMonth.Column(1) & ", " & Me!CbxYear
Me!Calendar.Value = Date()
Me!CalendarDay = 0
7. Put the following code in the AfterUpdate event of CbxYear:
Me!LblMonthYear.Caption = Me!CbxMonth.Column(1) & ", " & Me!CbxYear
Me!Calendar.Value = DateSerial(Me!CbxYear,Me!CbxMonth,1)
Me!CalendarDay = 0
8. Put the following code in the AfterUpdate event of CbxMonth:
Me!LblMonthYear.Caption = Me!CbxMonth.Column(1) & ", " & Me!CbxYear
Me!Calendar.Value = DateSerial(Me!CbxYear,Me!CbxMonth,1)
Me!CalendarDay = 0
**Me!NewMonth = Me!CbxMonth.Column(1)

** This line of code returns the new month for the calendar. I don't know
how you use it relative to your subform so you may need to change this line
of code.

The above sets your calendar to the current date when your form with the
calendar opens. Selecting a Year or Month in the comboboxes resets your
calendar and the label to the selected Year and Month. "1" is used in the
DateSerial expressions just because that expression needs a number for the
day. Me!CalendarDay = 0 immediately removes "1" from being selected so that
your calendar looks like you now need to select a day.

You will be able to now select a new month and execute whatever code you
need at ** before needing to select a day.


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com

If you can't get the help you need in the newsgroup, I can help you for a
very reasonable fee. Over 1000 Access users have come to me for help.
Need a month calendar or 7 day calendar? Need appointment scheduling? Need
room reservations scheduling? Need employee work scheduling? Contact me!
 
S

StopThisAdvertising

PC Datasheet said:
If you can't get the help you need in the newsgroup, I can help you for a
very reasonable fee. Over 1000 Access users have come to me for help.

These 1000 (if at all a real figure..) is only the result of
-- 4 years abusing the newsgroups.
-- 4 years blatantly advertising and job hunting.

You only care about making money, and you act as if the groups are your private hunting ground.
So why would ANYBODY ever trust a person like you and hire you?
********************************************************
Need a month calendar or 7 day calendar? Need appointment scheduling? Need
room reservations scheduling? Need employee work scheduling? Contact me!

Please Steve, do contact a psychiatrist ...

Arno R
 
K

Keith W

PC Datasheet said:
Need a month calendar or 7 day calendar? Need appointment scheduling? Need
room reservations scheduling? Need employee work scheduling? Contact me!

I thought that was particularly hilarious. I could just imagine the whole
of the group mentally answering "no" to each question. :blush:)
 
G

Gil D.

Hello PC Datasheet,

Thank you for your help.
This is an excellent solution. It solved my problem.

Thank you
Gil D.
 
S

StopThisAdvertising

Gil D. said:
Hello PC Datasheet,

Thank you for your help.
This is an excellent solution. It solved my problem.

Thank you
Gil D.

Hello Gil,
What's your opinion on PC's jobhunting?

Arno R
 

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