Calendar Control Changes Month

J

JamesJ

I'm using AC 2007. I have 2 Calendar Controls on a form. I want one cal
to display the current month and the other to display the next month. I have
this code in the OnLoad of the form:

Private Sub Form_Load()

Me.ctlCal.Value = Now()
Me!ctlCalNextMonth.NextMonth
Me!ctlCalNextMonth.Value = "" 'this is to prevent the highlighting
of a date

End Sub

What happens is when I put the form i design view and save changes
ctlCalNextMonth
displays a different month at runtime and in design view. Seems when I
delete and then
create a new cal control it's ok until I put the form in design view.
I'm sure there's a better way to have the control display the next month.

Any help will be appreciated,
James
 
L

Linq Adams via AccessMonster.com

I'm confused by a couple of things here, maybe because I don't run v2007. Is

.NextMonth

really a property of your calendar control, or is this just something you've
made up, hoping it would set the calendar to the following month? This is not
a property in v2000-2003, and may be responsible for the erratic behavior.

Also, your statement

"Seems when I delete and then create a new cal control it's ok until I put
the form in design view"

The form has to already be in Design View in order to delete or create a new
calendar control. Some clarification of this statem,ent is in order, I think.

In the form's OnLoad event, this code

Me!ctlCalNextMonth.NextMonth = DateSerial(Year(Date), Month(Date) + 1, 1)

should set the calendar to the frist day of the next month.
 
J

JamesJ

I found the property in a book and it was the onclick of a command button.
It would advance a Calendar Control 1 month so I gave it a shot.

I pasted the example but I got a error saying does not support the property
or
method or something to that effect. I removed the .NextMonth and it seems
to have done the trick. The Calendar Control is displaying June.

Me!ctlCalNextMonth = DateSerial(Year(Date), Month(Date) + 1, 1)

Not familiar with date functions or expressions so I appreciate the help

Thanks,
James
 
L

Linq Adams via AccessMonster.com

Either the example was from a language other than VBA (VBA and VB6, BTW, are
NOT the same language) or the author had written/modified a custom property.

Glad you got it fixed.

Linq
 
C

Chuck

I found the property in a book and it was the onclick of a command button.
It would advance a Calendar Control 1 month so I gave it a shot.

I pasted the example but I got a error saying does not support the property
or
method or something to that effect. I removed the .NextMonth and it seems
to have done the trick. The Calendar Control is displaying June.

Me!ctlCalNextMonth = DateSerial(Year(Date), Month(Date) + 1, 1)

In the properties for the calendar control set MonthColumns to 2
This will make 2 months side by side. Set the StartOfWeek to 1 so the left
hand column in each month will be Sun. Set it to 2 if you want the left hand
column to be Mon.

Paste the following code into the form module.

Private Sub Form_Load()
Me.{the calendar control name}.Value = Now()
End Sub

The left month will show the current year, month, and day and the current day
will be circled in red and highlighted in gray.
The right month will show the current year, the next month, and day but no day
will be circled or highlighted.

Chuck
 

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