Error when right Code for Calendar Popups

G

Guest

I have gone to this following website to setup my calendar in my form:
http://www.fontstuff.com/access/acctut09.htm

Now when I go to my form and click on my calender to pop-up I get an Error:
Run Time Error "424" Object Required. I'm not for sure on why I am getting
this error. Below is my code I have written for it so far and any advice
would be Greatly Appreciated.

Private Sub Training_Date_MouseDown(Button As Integer, Shift As Integer, X
As Single, Y As Single)
ocxCalendar.Visible = True
ocxCalendar.SetFocus
If Not IsNull(Training_Date) Then
ocxCalendar.Value = Training_Date.Value
Else
ocxCalendar.Value = Date
End If
End Sub
 
G

Guest

Ok, I figured this one out on my own. I has the wrong name for my calender
in the code, but now I do need help. How do I get the date to set when I
click on the month and day. It's not changing to the date I choose...
 
M

msnews.microsoft.com

I'm sure there are other ways to do this but here is one suggestion.
Add code like this to the forms module
Private Sub Calendar_Click()
' Set Date to the selected date and hide the calendar.
Training_Date.Value= Calendar.Value
<next field on form>.SetFocus
Calendar.Visible = False
End Sub
 
G

Guest

Ok, I tried the code below and it still isn't working. This is what I have
Private Sub Calendar7_Click()
' Set Date to the selected date and hide the calendar.
Training_Date.Value = Calendar7.Value
Did_They_Attend_Training_.SetFocus
Calendar7.Visible = False

Did_They_Attend_Training_= Next field in Form. It is a checkbox. Please
help, I have looked at some of the other code and I'm not for sure on how to
use it. I'm new at going into the code and making changes.
 
M

msnews.microsoft.com

OK so I'm not an MVP, but I am a WANNABE..
I have been working with this calendar code many times, and I just
double checked what I have and I've stripped out all the extras, all
the hides, and set focus, and what I have still works. Here is the jest
of what I have made work. 2 Private Subs.

The first is an OnClick for the date field that is to be filed.

Private Sub Date_Received_click()
' Show Calendar and set its date.
Calendar.Visible = True
' Set to today if SDate has no value.
Calendar.Value = IIf(IsNull([Date Received]), Date, [Date
Received].Value)
End Sub

AND the second passes the date back to the field on the form.
Private Sub Calendar_Click()
' Set Date to the selected date and hide the calendar.
[Date Received].Value = Calendar.Value
' Calendar.Visible = False
End Sub

AS you can see I've commented out some of the extra lines just
to show what the basics are, and this works. NOW, there is something in you
code that makes me wonder if you are really using the calendar name or the
CLASS. if you set a break point on the >> Private Sub Calendar7_Click()
Line and the click the date field you should be able to step through the
code with F8 and observe each step to better determine what is happening.

I hope this helps.
 
G

Guest

That worked for me! Thanks!

msnews.microsoft.com said:
OK so I'm not an MVP, but I am a WANNABE..
I have been working with this calendar code many times, and I just
double checked what I have and I've stripped out all the extras, all
the hides, and set focus, and what I have still works. Here is the jest
of what I have made work. 2 Private Subs.

The first is an OnClick for the date field that is to be filed.

Private Sub Date_Received_click()
' Show Calendar and set its date.
Calendar.Visible = True
' Set to today if SDate has no value.
Calendar.Value = IIf(IsNull([Date Received]), Date, [Date
Received].Value)
End Sub

AND the second passes the date back to the field on the form.
Private Sub Calendar_Click()
' Set Date to the selected date and hide the calendar.
[Date Received].Value = Calendar.Value
' Calendar.Visible = False
End Sub

AS you can see I've commented out some of the extra lines just
to show what the basics are, and this works. NOW, there is something in you
code that makes me wonder if you are really using the calendar name or the
CLASS. if you set a break point on the >> Private Sub Calendar7_Click()
Line and the click the date field you should be able to step through the
code with F8 and observe each step to better determine what is happening.

I hope this helps.


KRB said:
Ok, I tried the code below and it still isn't working. This is what I
have
Private Sub Calendar7_Click()
' Set Date to the selected date and hide the calendar.
Training_Date.Value = Calendar7.Value
Did_They_Attend_Training_.SetFocus
Calendar7.Visible = False

Did_They_Attend_Training_= Next field in Form. It is a checkbox. Please
help, I have looked at some of the other code and I'm not for sure on how
to
use it. I'm new at going into the code and making changes.
 

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