Using a form to run a report between two dates

donsi

Registered User.
Local time
Yesterday, 22:48
Joined
Sep 1, 2016
Messages
73
I have Report form which runs report per criteria entered. If it is based on single txtbox or cbobox, then I do not have a problem, but when it is multiple boxes then it doesn't produce the results I want. I.e. I want to get a report between two different dates, I tried below Macros but it only pulls report for TxtGDFrom textbox.

[GDate]=[Forms]![FrmGDayAlphaReport]![TxtGDFrom] And [Forms]![FrmGDayAlphaReport]![TxtGDTo]

if I use below Macro, it produces blank report
[GDate]=[Forms]![FrmGDayAlphaReport]![TxtGDFrom] And [GDate]=[Forms]![FrmGDayAlphaReport]![TxtGDTo]

I tried using BETWEEN function, but it is giving me an error.
[GDate]=Between[Forms]![Copy Of FrmGDayAlphaReport]![TxtGDFrom] And [Forms]![Copy Of FrmGDayAlphaReport]![TxtGDTo]

This must be simple, but having a hard time figuring out.

Also, i would like to display criteria on my report. Is it possible? If so, how?

Please help.
 
Last edited:
I don't use macros so unsure of the exact syntax, but in the last you wouldn't want the "="; Between replaces it. In the second, you'd want ">=" and "<=", not just "="
 
I don't use macros so unsure of the exact syntax, but in the last you wouldn't want the "="; Between replaces it. In the second, you'd want ">=" and "<=", not just "="

I am open to VBA, but don't' know much (same with macro though). Until now Macro seemed to be working for me so took that route.

Thanks
 
So did any of those changes help?
 
you dont need vba , nor macro,
make a query that looks at the form txtSTart and txtEnd boxes.

select * from table where [date] between forms!myForm!txtSTart and forms!myForm!txtEnd
 
My rule of thumb for using query criteria vs a wherecondition is whether the criteria will always be applied or not. I want the end product (form or report) to be as flexible as possible. If it will always include a date filter, I'll use a query criteria. Otherwise I'm more likely to use a wherecondition, given the flexibility I have in VBA.
 
My rule of thumb for using query criteria vs a wherecondition is whether the criteria will always be applied or not. I want the end product (form or report) to be as flexible as possible. If it will always include a date filter, I'll use a query criteria. Otherwise I'm more likely to use a wherecondition, given the flexibility I have in VBA.

Agreed on being flexible. I only have one query and different reports based on criteria.

I just solved it with you suggestions. It took me long to get your point of not having "=" sign. and that was the issue. LOL.

[GDate]Between[Forms]![Copy Of FrmGDayAlphaReport]![TxtGDFrom] And [Forms]![Copy Of FrmGDayAlphaReport]![TxtGDTo]

Thanks for your help.
 
Happy to help! You're not saying that the only difference between the reports is criteria, are you? Normally you'd have one report, and apply different criteria to it.
 
Happy to help! You're not saying that the only difference between the reports is criteria, are you? Normally you'd have one report, and apply different criteria to it.

I have one query to generate different report by passing different criteria.
 

Users who are viewing this thread

Back
Top Bottom