Symbol

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I created a calendar form by following an example in the platinum edition
book "Using Access 97", even though I have Access 2003 and the XP operating
system. I created a blank form, added the ActiveX calendar control and added
some coding to open the form to a specific date and to update a text box and
label box after a user chooses a new date on the calendar. However, one of
the "sub's" in the book is giving me trouble. I typed it below. The sub is
supposed to change the calendar to a previous or next week, month or year,
depending on which of 6 command buttons the user clicks.

Sub cmd{Next|Previous}{Week|Month|Year}_Click()
'Purpose: Use the Next or Previous period method to increment or decrement
the period
ocxCalendar.Object.{Next|Previous}{Week|Month|Year}
End Sub

There is something about a symbol I am using that causes this to not work.
I think it is the symbol separating the next, previous, week, month and year.
It is the two vertical dashes and it is on the back slash key above the
enter key on my keyboard.

Can someone tell me what needs to be changed to make the command buttons
work on this form? Thanks.
The ultimate goal is to have whatever date the user selects on the calendar
be used as the input for a beginning date in a report based on a parameter
query. The user will also have to select a ending date for input into that
report. Again, thanks for the help. I will provide more info as needed.

Andy
 
Are you actually typing Sub cmd{Next|Previous}{Week|Month|Year}_Click()

I would suspect that that's a shortcut for creating a number of different
subs:

Sub cmdNextWeek_Click()
ocxCalendar.Object.NextWeek
End Sub

Sub cmdPreviousWeek_Click()
ocxCalendar.Object.PreviousWeek
End Sub

Sub cmdNextMonth_Click()
ocxCalendar.Object.NextMonth
End Sub

Sub cmdNextYear_Click()
ocxCalendar.Object.NextYear
End Sub

etc.
 
Hi, Your solution worked. However, somehow I broke the setting of the date
when opening the form. It used to work but not now. I created a new 2nd
calendar form and it opens with todays (the current) date but I cannot get
the original calendar form to open with the current date selected. Below is
the code. Let me know if you need anything else. I could just change the
new 2nd calendar form to match the old original calendar form but I would
like to know what I did to break the original calendar form. Thanks.

2nd Calendar Form:
Option Compare Database
Option Explicit

Private Sub Form_Open(Cancel As Integer)
'Purpose: Set the Date on Opening
Calendar0.Object.Value = Date

End Sub

Original Calendar Form:

Option Compare Database
Option Explicit

Private Sub Form_Open(Cancel As Integer)
'Purpose: Set the Date on Opening
ocxCalendar.Object.Value = Date
Call ocxCalendar_AfterUpdate
End Sub

Private Sub ocxCalendar_AfterUpdate()
'Purpose: Update the text boxes
lblDate.Caption = Format(ocxCalendar.Object.Value, "mm/dd/yy")
txtDate.Value = Format(ocxCalendar.Object.Value, "dddddd")
End Sub

Sub cmdNextDay_Click()
ocxCalendar.Object.NextDay
End Sub

Sub cmdPreviousDay_Click()
ocxCalendar.Object.PreviousDay
End Sub

Sub cmdNextWeek_Click()
ocxCalendar.Object.NextWeek
End Sub

Sub cmdPreviousWeek_Click()
ocxCalendar.Object.PreviousWeek
End Sub

Sub cmdNextMonth_Click()
ocxCalendar.Object.NextMonth
End Sub

Sub cmdPreviousMonth_Click()
ocxCalendar.Object.PreviousMonth
End Sub

Sub cmdNextYear_Click()
ocxCalendar.Object.NextYear
End Sub

Sub cmdPreviousYear_Click()
ocxCalendar.Object.PreviousYear
End Sub
 
Back
Top