Link to home
Start Free TrialLog in
Avatar of behest
behestFlag for United States of America

asked on

Click day in ActiveX Calendar in Access to call a report

Hello! I'm trying to set up an OnClick action that will allow users to click on a specific day on an ActiveX calendar added to an Access database. The click would call a report that would show that specific day's activities. OnClick doesn't seem to be working. I can get the report to open whenever I open the Calendar form but not by clicking on individual buttons. So, 1) how can I get a report to open by clicking on an individual day? and 2) what is the proper way to reference the specific day that is clicked on in the calendar when using it in the code? Your assistance is greatly appreciated!
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

What version of Access please?

You have to use the AfterUpdate event of the calendar control

Something like this to open a report with the same day as the calendar

DoCmd.OpenReport "rptOrders", acViewPreview, , "OrderDate=" & "#" & Calendar6 & "#"

Works fine for me

;-)

JeffCoachman
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of behest

ASKER

Jeff, thank you for the response. I tried using the line of code provided but still have the same issue. The daily report opens but is in no way linked to the square/day clicked on the calendar. I've got basic code that will return the day, month and year values for each day of the calendar that is clicked, so I know the data is in there somewhere. Is there something along the lines of Calendar1.value (or ~) that will allow me to link the specific day clicked?

OR

Looking at this from another perspective, could I link Calendar1.value to the specific date square via the expressions on the report, currently using  =Date() ...
<I tried using the line of code provided but still have the same issue.>
Which line of code?, the code I posted here, ...or the code from the sample Database I posted?

Remember you must change the names in the code to match the names in your specific database.

<I've got basic code that will return the day, month and year values for each day of the calendar>
Well, the calendar will return a single date.
This is all that is needed to filter the report.

Did you verify this functionality in the sample DB I posted?

JeffCoachman
Access-EEQ26902276SynchronizeAcc.mdb
Avatar of behest

ASKER

Jeff, I just received an inactive question messge. I'm in the middle of another project but will take a look at this again later this evening. Yes, I did test and replaced appropriate names in the code. More later....
Avatar of behest

ASKER

Hi! Back to this project now and working on setting up a new report that will work with your brilliance! Instead of a sales date, I've got start and end dates, so I need to pull anything within those dates. Hoping I can use something as simple as >= on the report. Will be back with the results.
Avatar of behest

ASKER

Everything is set up, the world should be a happy place to live in...but no. I'm told that I'm missing an operator. error 3075...syntax error (missing operator) in query expression 'Start date=#3/9/2011#'. It appears to want something between the "Start date=" and "#". I'm in 2007, btw. When I run yours it works without a problem. I don't have anything set up with >=...starting off simple to make sure it works then will grow from there. Any words of wisdom?
1. I thought you were using the calendar control to select the day?
2. Try to avoid using spaces in your names, ...but if your app is already designed with them, try it like this:
    "[Start Date]=" & "#" & Calendar6 & "#"

...This, again, presumes that you are using a calendar control to select the dates