tangledball
Registered User.
- Local time
- Today, 23:07
- Joined
- Mar 22, 2009
- Messages
- 14
I would be gratful if anyone could advise how i can open a report but only show entries between two dates using a command button?
I have the following expression which enables me to use a command button to open a report based on the current open record:
DoCmd.OpenReport stDocName, acViewPreview, , "[RecordID]= " & Me.[RecordID]
but how do i now extend that to allow me to open the same report, but only show entries between two dates that are recorded on a seperate form (Form Name Registration)? these are entered into individual fields and are manually input, so for agruments sake open and close dates, but i need my report to show me all the entries made between the open and close dates and relevent to the current open record and not all records.
At the moment I have a query that will allow me to enter the From - To dates, but this can get a bit messy as there are calculation fields in the report and in effect would calculate the wrong info if wrong dates are input, so would be useful if this can be done by just clicking a button with no manual intervention.
If anyone could provide a bit of an idiots guide how i can achieve this, I would be extremely grateful, as I have been working on some code that was provided as per below, but i makes no sense to me and I havent a clue what to do and am losing the will to live.
1) Place 2 textboxes viz. txtbegDate and txtendDate (Where?)
2) In properties sheet of these 2 boxes Select Short Date under Format (What for? and wheres the relationship between the text fields on the form and wherever i am supposed to put these text boxes?)
3) in click event of the command button use this code :
DoCmd.OpenReport stDocName, acViewPreview, , "[urdtabledatefieldname]>=# " & Me.txtbegDate _
" # And [urdtabledatefieldname]<=# " & Me.txtEndDate & "#"
(Tried this and many many variations, but I now only have three strands of hair left on my head)
Just for clarification, I have two forms... Registration Form which is where all the setup data goes and Absence Management Form which has a number of subforms for different types of absence. The Start and End Dates that I refer to are located on the registration form, but the data i wish to extract on the report is on the subform. I have my Report set up and the code above does open for the specific record that is being worked on... just need to incorporate the start and end date.
Hope I have been thorough in my explanation, but if any of you could help me out I'd be real happy. P.s I am in the United Kingdom.
Thanks for any help.
I have the following expression which enables me to use a command button to open a report based on the current open record:
DoCmd.OpenReport stDocName, acViewPreview, , "[RecordID]= " & Me.[RecordID]
but how do i now extend that to allow me to open the same report, but only show entries between two dates that are recorded on a seperate form (Form Name Registration)? these are entered into individual fields and are manually input, so for agruments sake open and close dates, but i need my report to show me all the entries made between the open and close dates and relevent to the current open record and not all records.
At the moment I have a query that will allow me to enter the From - To dates, but this can get a bit messy as there are calculation fields in the report and in effect would calculate the wrong info if wrong dates are input, so would be useful if this can be done by just clicking a button with no manual intervention.
If anyone could provide a bit of an idiots guide how i can achieve this, I would be extremely grateful, as I have been working on some code that was provided as per below, but i makes no sense to me and I havent a clue what to do and am losing the will to live.
1) Place 2 textboxes viz. txtbegDate and txtendDate (Where?)
2) In properties sheet of these 2 boxes Select Short Date under Format (What for? and wheres the relationship between the text fields on the form and wherever i am supposed to put these text boxes?)
3) in click event of the command button use this code :
DoCmd.OpenReport stDocName, acViewPreview, , "[urdtabledatefieldname]>=# " & Me.txtbegDate _
" # And [urdtabledatefieldname]<=# " & Me.txtEndDate & "#"
(Tried this and many many variations, but I now only have three strands of hair left on my head)
Just for clarification, I have two forms... Registration Form which is where all the setup data goes and Absence Management Form which has a number of subforms for different types of absence. The Start and End Dates that I refer to are located on the registration form, but the data i wish to extract on the report is on the subform. I have my Report set up and the code above does open for the specific record that is being worked on... just need to incorporate the start and end date.
Hope I have been thorough in my explanation, but if any of you could help me out I'd be real happy. P.s I am in the United Kingdom.
Thanks for any help.