Extract user input from query into report

J

JJ

I have a query setup looking for particular dates as one of the fields.
EG. Between [Enter Date1] and [Enter Date2] or [Enter Date3].

Is there a simple way to save the user entry and retrieve them in a report?
I need to perform a calcualtion of number of days based on these entries.
 
J

John Spencer MVP

In the report you can refer directly to [Enter Date1], [Enter Date2], and
[Enter Date3] as if they were fields. They won't show up in the display
fields listing, but they should be available and can be used a the source for
controls and can be referenced in VBA. You must use the exact name as
included in the query.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
J

JJ

Thanks John, this is getting me in the right direction. I'm not an expert in
Access... when I referenced [Date1] in my report it's wanting me to input
something, not referencing what I already type in. I put as the control
source for a text box.
Do I have to write code in my report to retrieve this info?

John Spencer MVP said:
In the report you can refer directly to [Enter Date1], [Enter Date2], and
[Enter Date3] as if they were fields. They won't show up in the display
fields listing, but they should be available and can be used a the source for
controls and can be referenced in VBA. You must use the exact name as
included in the query.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
I have a query setup looking for particular dates as one of the fields.
EG. Between [Enter Date1] and [Enter Date2] or [Enter Date3].

Is there a simple way to save the user entry and retrieve them in a report?
I need to perform a calcualtion of number of days based on these entries.
 
J

John W. Vinson

I have a query setup looking for particular dates as one of the fields.
EG. Between [Enter Date1] and [Enter Date2] or [Enter Date3].

Is there a simple way to save the user entry and retrieve them in a report?
I need to perform a calcualtion of number of days based on these entries.

The simplest way would be to use a Form rather than prompts. Create a little
unbound form frmCrit with textboxes Date1, Date2 and so on, and in your query
refer to

[Forms]![frmCrit]![Date1]
 
J

JJ

Alright, created a form with 3 boxes, Date1, Date2, Date3. For testing
purposes I just referenced Date1 from the form in the query. Works great!
However, when I reference the text box "Date1" from the form in my report I
get a #Name? error.
Any ideas? Appreciate the help.

John W. Vinson said:
I have a query setup looking for particular dates as one of the fields.
EG. Between [Enter Date1] and [Enter Date2] or [Enter Date3].

Is there a simple way to save the user entry and retrieve them in a report?
I need to perform a calcualtion of number of days based on these entries.

The simplest way would be to use a Form rather than prompts. Create a little
unbound form frmCrit with textboxes Date1, Date2 and so on, and in your query
refer to

[Forms]![frmCrit]![Date1]
 
J

JJ

Hi John, after closer inspection I don't think the query is opening up the
form. When I run the query a pop-up box open asking to enter a parameter
value.
I have referenced the form in the criteria.

John W. Vinson said:
I have a query setup looking for particular dates as one of the fields.
EG. Between [Enter Date1] and [Enter Date2] or [Enter Date3].

Is there a simple way to save the user entry and retrieve them in a report?
I need to perform a calcualtion of number of days based on these entries.

The simplest way would be to use a Form rather than prompts. Create a little
unbound form frmCrit with textboxes Date1, Date2 and so on, and in your query
refer to

[Forms]![frmCrit]![Date1]
 
J

John W. Vinson

Hi John, after closer inspection I don't think the query is opening up the
form. When I run the query a pop-up box open asking to enter a parameter
value.
I have referenced the form in the criteria.

Sorry... should have added that detail!

No, it WON'T open the form for you. Open the form first. It's convenient to
put a command button on the form to open the report.
 
J

JJ

PERFECT!! It Works! Thank You.
John W. Vinson said:
Sorry... should have added that detail!

No, it WON'T open the form for you. Open the form first. It's convenient to
put a command button on the form to open the report.
 

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