Parameter Form Help

  • Thread starter knowshowrosegrows
  • Start date
K

knowshowrosegrows

I have a form that lets me choose a region and a date range and when I hit
the cmdRunRpt button it opens the report using those parameters.

The current VBA code I have for the cmdRunRpt button is:
DoCmd.OpenReport "rptEventInfoByRegion/Date", acPreview, , "Reg LIKE '" &
Me.ChooseRegion & "'"

This works great for allowing me to choose the Region. I now need the code
to use the text boxes StartDate and EndDate to set the date range parameters
of the report.

Can someone take the above code and add some that will include the date range?
 
F

fredg

I have a form that lets me choose a region and a date range and when I hit
the cmdRunRpt button it opens the report using those parameters.

The current VBA code I have for the cmdRunRpt button is:
DoCmd.OpenReport "rptEventInfoByRegion/Date", acPreview, , "Reg LIKE '" &
Me.ChooseRegion & "'"

This works great for allowing me to choose the Region. I now need the code
to use the text boxes StartDate and EndDate to set the date range parameters
of the report.

Can someone take the above code and add some that will include the date range?

Regarding >> "Reg LIKE '" & Me.ChooseRegion & "'" <<
The Like operator is used with a wildcard.

"Reg LIKE '" & Me.ChooseRegion & "*'"

will find all records that begin with the value entered in
[ChooseRegion], i.e. enter "Sou" and it will return 'South',
'Southeast', 'Southwest', etc.

If you are not using wildcards, then you should use the "=" operator,
not the Like operator.

"Reg = '" & Me.ChooseRegion & '"'

To add the StartDate and EndDate values to the above (using Like and a
Wildcard), try:

"Reg LIKE '" & Me.ChooseRegion & "*' AND [YourDateField] Between #" &
Me.[StartDate] & "# AND #" & Me.[EndDate] & "#"

Not using a wildcard, it would be:

"Reg = '" & Me.ChooseRegion & "' AND [YourDateField] Between #" &
Me.[StartDate] & "# AND #" & Me.[EndDate] & "#"
 
K

knowshowrosegrows

Thanks for your quick reply and it works great.

--
Thanks

You all are teaching me so much


fredg said:
I have a form that lets me choose a region and a date range and when I hit
the cmdRunRpt button it opens the report using those parameters.

The current VBA code I have for the cmdRunRpt button is:
DoCmd.OpenReport "rptEventInfoByRegion/Date", acPreview, , "Reg LIKE '" &
Me.ChooseRegion & "'"

This works great for allowing me to choose the Region. I now need the code
to use the text boxes StartDate and EndDate to set the date range parameters
of the report.

Can someone take the above code and add some that will include the date range?

Regarding >> "Reg LIKE '" & Me.ChooseRegion & "'" <<
The Like operator is used with a wildcard.

"Reg LIKE '" & Me.ChooseRegion & "*'"

will find all records that begin with the value entered in
[ChooseRegion], i.e. enter "Sou" and it will return 'South',
'Southeast', 'Southwest', etc.

If you are not using wildcards, then you should use the "=" operator,
not the Like operator.

"Reg = '" & Me.ChooseRegion & '"'

To add the StartDate and EndDate values to the above (using Like and a
Wildcard), try:

"Reg LIKE '" & Me.ChooseRegion & "*' AND [YourDateField] Between #" &
Me.[StartDate] & "# AND #" & Me.[EndDate] & "#"

Not using a wildcard, it would be:

"Reg = '" & Me.ChooseRegion & "' AND [YourDateField] Between #" &
Me.[StartDate] & "# AND #" & Me.[EndDate] & "#"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top