Using a Calendar control to update the current form

  • Thread starter Thread starter Brian123
  • Start date Start date
B

Brian123

Guest
I would like to open a form and using a calendar control, I would like to view data based upon the value of the date I've selected in the calendar control. I've used the calendar control to view and print reports based upon unbound text boxes, but I cannot seem to use the calendar to just simply change the date of the form. For example; Click August 1 and the form shows the data from august 1, then click jun 18 and the forms shows data from jun 18. Thanks in advance for any help. Brian.
 
Take the date from the calendar control, make this a criteria for the an SQL, (= date or >date), make this SQL your form's recordsource
 
Hi
I have a Calendar Form called frmLab_Daily_Calendar and the Calendar control is named ocxDaily_Calendar.
I use this procedure to open a form based on the users selection of a particular date.
There may be more steps than I need but it works well for my purposes.

Create an unboud text box on your calendar form. Call it txtDaily_Date and set its visible property to No.
Add these codes to the AfterUpdate and Click events for your Calendar Control.

Private Sub ocxDaily_Calendar_AfterUpdate()

txtDaily_Date.Value = Format(ocxDaily_Calendar.Object.Value, "ddddd")

End Sub

Private Sub ocxDaily_Calendar_Click()
On Error GoTo Err_ocxDaily_Calendar_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmLab_Daily"

stLinkCriteria = "#" & Me![txtDaily_Date] & "#"

DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
DoCmd.Maximize


Exit_ocxDaily_Calendar_Click:
Exit Sub

Err_ocxDaily_Calendar_Click:
Resume Exit_ocxDaily_Calendar_Click
End Sub

If you wish to view the form in Normal view change the acFormsDS to acNormal.

I then have a query that the frmLab_Daily is based on. In the Criteria row of the Date field for that query enter this.
[Forms]![frmLab_Daily_Calendar]![txtDaily_Date]

Hope this helps you out.

Any questions you can email me.

D.J.

[This message has been edited by DJBummy (edited 08-19-2001).]

[This message has been edited by DJBummy (edited 08-19-2001).]
 

Users who are viewing this thread

Back
Top Bottom