Calendar Control

RichGags

Registered User.
Local time
Today, 17:48
Joined
Jun 30, 2003
Messages
39
Calendar Control Help Please

Hi, Im very new to access but I think I have the basic idea of it.

I have a form which I added Calendar Control 10.0, when I double click a date on the calendar I want it to invoke a query based on only the date I picked. (My table is an event planner, so when I double click a date, I want to see all the events on that day only). Right now, Ive got this: (which is showing me every record in my database)

Private Sub Calendar3_DblClick()
DoCmd.OpenQuery "BOOKINGS Query"
End Sub



How do I get it to show me only the events I have on that date? I guess I have to bind the calendar somehow to sort on my "BOOKING-DATE" field, but I dont know how or where to do it. Thanks in advance.
 
Add an unbound text box to your form. Have the dbl click event place the date selected in the calendar into that control. Have the query get the date from the control with code similar to this in the Criteria line of the date field:

[Forms]![FormName]![ControlName]

hth,
Jack
 
You lost me...
Im just trying to invoke a query based on the date I double click.
Do I change this part?

Private Sub Calendar3_DblClick()
DoCmd.OpenQuery "BOOKINGS Query"
End Sub


Thanks
 
Code similar to this plus the criteria I suggested (using your actual form and control names) in the previous post should do the trick:

Private Sub Calendar3_DblClick()
Me.UnboundControlOnForm = Me.NameOfCalendarControl.Value
DoCmd.OpenQuery "BOOKINGS Query"
End Sub

The above code will put the date into the unbound control on the form and the query will use it to filter your records.

hth,
Jack
 
Ok, Ive created the unbound control on the form field, named "UnboundControlOnForm" and made the Visual basic screen look like this.

Private Sub Calendar3_DblClick()
Me.UnboundControlOnForm = Me.Calendar3.Value
DoCmd.OpenQuery "BOOKINGS Query"
End Sub


But its still giving me all the records, do I have to do something to the query? Thanks.
 
Last edited:
Add this to the Criteria line of your query in the Date column. Change the names as appropriate:

[Forms]![FormName]![ControlName]

Also, is the name of your unbound control "UnboundControlOnForm"? If not, change your code to the actual name of the control. Be sure and do the same with the code in the query.

Are ya with me?

Jack
 
Ok, Im with you. Thanks for all your help....Im close to getting it. I think Im just a little confused on the "UnboundControlOnForm".

I created a field with the name "UnboundControlOnForm" and added it to my form. When I double click the calender date, it puts the date that I click into that field and a report opens, but the report is not correct. It is putting the "previously" selected date into the field and spits out a report based on a different date altogether.

Should I have this field on the form....?
 
Then it changes the BOOKING DATE field of whatever record Ive got showing to the calendar selected date!
 
This statement is what I was basing my answer on, "...when I double click a date on the calendar I want it to invoke a query based on only the date I picked. (My table is an event planner, so when I double click a date, I want to see all the events on that day only). "

Now, do you want to show all records that have the same booking date as the BOOKING DATE shown on the form OR do you want the Calendar control to select the date for the query?

If you want the BOOKING DATE to be the filter then remove the unbound text box. Remove the line of code in the on Dbl Click event the set the unbound control. Add this line of code to the Criteria line of the Query:

[Forms]![NameOfFormWithBookingDate]![BOOKING DATE]

Now the query will show all the records that have the same date as the selected records BOOKING DATE. If this is NOT what you want then run pass me one more time what it is you want the Calendar control to do...

Jack
 
Ok, thanks again for sticking with me on this....

I have a whole table full of bookings for the future with client names and dates. I have a calendar control on the form. When I click on 10/4/2004 date on the calendar, I want the query to give me a list like this:

Booking Date Name Who is doing party
10/4/2004 Joe Schmoe DJ Johnny
10/4/2004 Lisa Smith DJ Lou

I dont want it to change the date of whatever record Im looking at. I just want a quick report of what is going on, on that day.

What should the "Control Source" be on the data tab of the calender? It would be nice that whatever date today is, thats where the calendar should be when I first run the program.
 
1. The Control Source for the Calendar control should be blank.

2. In the On Load event of the form use code like this to set the Calendar to todays date:

Me![Calendar3].Value = Date

3. Go back and add an unbound text box control and it can be hidden if you like.

4. Use this code in the Dbl Click event of the Calendar control

Private Sub Calendar3_DblClick()
Me.UnboundControlOnForm = Me.Calendar3.Value
DoCmd.OpenQuery "BOOKINGS Query"
End Sub

5. Add this to the criteria line of the 'booking date' column in your query:

[Forms]![YourFormName]![NameOfUnboundControlOnForm]

That should do it. If it still does not work then strip out any confidential or propriatry information, compact and zip your db and post it. I can look at Access97 and Access2000 db's so if you have Access2002 you will have to save the demo as an Access2000 version.

Jack
 
This was awesome! In addition to this is there a way to highlight the date on the calendar that there are event scheduled for?

Any help would be appreciated!
 
Hmmm one glitch though, it keeps saying that the macro or group doesnt exist, although if I hit ok it still pulls up the query?
 

Users who are viewing this thread

Back
Top Bottom