Active X Objects (1 Viewer)

Rob.Mills

Registered User.
Local time
Today, 16:22
Joined
Aug 29, 2002
Messages
871
I have a form with the Calendar 9.0 control on it. I want to use it to filter the records on the subform. I haven't found an easy way to do this. I've setup the code below in the Update event of the calendar but when I change the date on the calendar nothing happens. Please help.


Private Sub ocxCalendar_Updated(Code As Integer)

Dim dtm As Date
Dim str As String

dtm = Me!ocxCalendar.Value

str = "SELECT tblMain.txtID, tblMain.txtEmployee, tblMain.txtType, "
str = str & "tblMain.txtPTOTime, tblMain.txtNote, tblMain.txtDate "
str = str & "FROM tblMain WHERE (((tblMain.txtDate)=#" & dtm & "#));"

Me!sfrmDetails.Form.RecordSource = str

End Sub
 

Jack Cowley

Registered User.
Local time
Today, 20:22
Joined
Aug 7, 2000
Messages
2,639
I would use the Calendar to fill in an unbound field on the form and then the Child/Master Links should filter the subform. Since the Calendar does not have an On Click property you will have to write one to have the value selected fill in the unbound control.

hth,
Jack
 

Rob.Mills

Registered User.
Local time
Today, 16:22
Joined
Aug 29, 2002
Messages
871
Hi Jack,

Thanks for your reply. I'm not experienced at creating properties. Don't want to ask you to tell me exactly how to do it but is there somewhere you can lead me to learn how?
 

Jack Cowley

Registered User.
Local time
Today, 20:22
Joined
Aug 7, 2000
Messages
2,639
Rob -

It is really easy once you know how to do it. Take a look...

Private Sub Calendar_Click()
Me.Text1 = Me.Calendar.Value
End Sub

Just type that in in the code page for your form. The above assumes that your Calendar Control is named "Calendar" and that the date you click on is going to be put into a field called Text1. If you put Me.Calendar.Value = Date in the On Current event of the form the Calendar will open with the current date selected.

hth,
Jack
 

Jack Cowley

Registered User.
Local time
Today, 20:22
Joined
Aug 7, 2000
Messages
2,639
Rob -

Glad you got it working! Continued success....

Jack
 

Users who are viewing this thread

Top Bottom