Calendar Month

G

Guest

Simple question (I hope):

I placed a Calendar control on a report (to make it look spiffy). Now I
would like to print the report with the Calendar heading based on a value the
user inputs.

ie: For October 2007 - print the Calendar with "October" in the heading and
the drop-down box next to the heading and "2007" in the drop-down box next to
the month drop-down.

I thought it would work if I put in the following code:

Private Sub Report_Open(Cancel As Integer)
MoNum = InputBox("Enter the month # to print")
Cal1.Month = MoNum 'also tried "Cal1.Month.Value" &
"Cal1.Value"
End Sub

But it doesn't. Any pointers would be greatly appreciated.
 
G

Guest

Cal1.Month should work....however that property is an Integer Value.
The Inputbox returns a String.
In other words: 12 does not equal "12"
You must compare apples to apples....not apples to oranges.

3 suggestions:
Either
1. Convert the Cal1.Month to a string before you do a compare. See Cstr()
function
OR
2. Convert the Inputbox return value to an integer before you do a compare.
See CInt() function
OR
3. Define the Inputbox's return value (MoNum) as Variant.
 
G

Guest

Thanks for the suggestions. I looked at the CInt function - understood it -
but wasn't able to make it work. So, I did it another way.

I needed the calendar to show up with the Month heading only (no data, etc)
for a draft printout to be filled in manually (and then transferred into the
database - that part is done).

So, I just put it on a form instead of a report and let the user select the
month (and even date, if they want), since it will not really be used within
the db - only for manual scribbling.

Thanks again.
 
C

CompGeek78

Thanks for the suggestions. I looked at the CInt function - understood it -
but wasn't able to make it work. So, I did it another way.

I needed the calendar to show up with the Month heading only (no data, etc)
for a draft printout to be filled in manually (and then transferred into the
database - that part is done).

So, I just put it on a form instead of a report and let the user select the
month (and even date, if they want), since it will not really be used within
the db - only for manual scribbling.

Thanks again.

You could use something along these lines:

Dim intMonth As Integer
intMonth = InputBox("Please enter a month number:")
Calendar0.Value = DateSerial(Year(Now()), intMonth, 1)

This simply sets the calendar control to the current year, whatever
month they typed in, with the first day of that month selected. Simply
adjust the values in the dateserial function to adjust what date gets
picked.

Keven Denen
Exalen Training, LLC
 

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