Default Value when input data

M

Maracay

Hi Guys

I have a query with detail data, one of the fields contain the document's
date (DocDate), because there are some many reports derivate from this query
and I needs to type the date range every time I open a report, and more of
the time I analyze the different reports in the same date range, what I need
is to create a master table with 2 fields DateFrom and DateTo, and put the
date range I want to work with. I want all my reports to take the default
value date from this master table, but with the option to change the dates if
I need it before the report execute.

Thanks, any help will be appreciated
 
M

Marshall Barton

Maracay said:
I have a query with detail data, one of the fields contain the document's
date (DocDate), because there are some many reports derivate from this query
and I needs to type the date range every time I open a report, and more of
the time I analyze the different reports in the same date range, what I need
is to create a master table with 2 fields DateFrom and DateTo, and put the
date range I want to work with. I want all my reports to take the default
value date from this master table, but with the option to change the dates if
I need it before the report execute.


I guess using a table for this kind of thing is feasible,
but seems a bit roundabout compared to using an unbound
form. Almost every one should use a form with text and/or
combo boxes for the criteria values and a button for each
report.

The code for a button in your case could be something like:

Dim stWhere As String
stWhere = "DocDate Between " & Format(txtFrom,
"\#yyyy-m-d\#") & " And " & Format(txtTo, "\#yyyy-m-d\#")
DoCmdOpenReport "reportname", acviewPreview, _
WhereConditions:= stWhere

This way the query does not need the criteria, do you won't
be prompted for it.

If you situation is too complicated for the WhereCondition
argument, then remove that part of the code and change the
queries to use parameter criteria like:
Forms!theform.txtFrom
inatead of a prompt parameter like:
[Enter From Date]
 
M

Maracay

Hi Marshall,

I think you took me to my next question and is how can I access my reports
in an organized way, do you have a link where I can see the different ways to
organize my reports, calling the reports from a form or something like that.

Thanks


Marshall Barton said:
Maracay said:
I have a query with detail data, one of the fields contain the document's
date (DocDate), because there are some many reports derivate from this query
and I needs to type the date range every time I open a report, and more of
the time I analyze the different reports in the same date range, what I need
is to create a master table with 2 fields DateFrom and DateTo, and put the
date range I want to work with. I want all my reports to take the default
value date from this master table, but with the option to change the dates if
I need it before the report execute.


I guess using a table for this kind of thing is feasible,
but seems a bit roundabout compared to using an unbound
form. Almost every one should use a form with text and/or
combo boxes for the criteria values and a button for each
report.

The code for a button in your case could be something like:

Dim stWhere As String
stWhere = "DocDate Between " & Format(txtFrom,
"\#yyyy-m-d\#") & " And " & Format(txtTo, "\#yyyy-m-d\#")
DoCmdOpenReport "reportname", acviewPreview, _
WhereConditions:= stWhere

This way the query does not need the criteria, do you won't
be prompted for it.

If you situation is too complicated for the WhereCondition
argument, then remove that part of the code and change the
queries to use parameter criteria like:
Forms!theform.txtFrom
inatead of a prompt parameter like:
[Enter From Date]
 
M

Marshall Barton

I don't know what your kind of "organized way" you have in
mind. Most people just add a button (using code similar to
below) to an appropriate form. I usually put the report's
button in the footer section of the same form that is used
to enter/edit the main data for the report (e.g. Print
Invoice button on the main Invoice form). OTOH, there are
times when I have creates a form with many buttons, each for
a different report and sometime a combination of the two.
--
Marsh
MVP [MS Access]

I think you took me to my next question and is how can I access my reports
in an organized way, do you have a link where I can see the different ways to
organize my reports, calling the reports from a form or something like that.


Marshall Barton said:
Maracay said:
I have a query with detail data, one of the fields contain the document's
date (DocDate), because there are some many reports derivate from this query
and I needs to type the date range every time I open a report, and more of
the time I analyze the different reports in the same date range, what I need
is to create a master table with 2 fields DateFrom and DateTo, and put the
date range I want to work with. I want all my reports to take the default
value date from this master table, but with the option to change the dates if
I need it before the report execute.


I guess using a table for this kind of thing is feasible,
but seems a bit roundabout compared to using an unbound
form. Almost every one should use a form with text and/or
combo boxes for the criteria values and a button for each
report.

The code for a button in your case could be something like:

Dim stWhere As String
stWhere = "DocDate Between " & Format(txtFrom,
"\#yyyy-m-d\#") & " And " & Format(txtTo, "\#yyyy-m-d\#")
DoCmdOpenReport "reportname", acviewPreview, _
WhereConditions:= stWhere

This way the query does not need the criteria, do you won't
be prompted for it.

If you situation is too complicated for the WhereCondition
argument, then remove that part of the code and change the
queries to use parameter criteria like:
Forms!theform.txtFrom
inatead of a prompt parameter like:
[Enter From Date]
 

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

Top