Access Reports

G

gg

Have a small employee database. Want to print ID cards for new hires.
report works fine for the whole file, but for one-at-a-time, it seems that
the report doesn't respect to filter - It wants to print all records
instead of the filtered table. Appreciate any help.

gg
 
C

Carl Rapson

gg said:
Have a small employee database. Want to print ID cards for new hires.
report works fine for the whole file, but for one-at-a-time, it seems that
the report doesn't respect to filter - It wants to print all records
instead of the filtered table. Appreciate any help.

gg

What mechanism are you using to print your report?

Carl Rapson
 
F

fredg

Have a small employee database. Want to print ID cards for new hires.
report works fine for the whole file, but for one-at-a-time, it seems that
the report doesn't respect to filter - It wants to print all records
instead of the filtered table. Appreciate any help.

gg

Your table should have a unique prime key field.
In my example it is named [RecordID].

Display your employee records on a form.
Add a command button.

On the command button's property sheet write
[Event Procedure]
on the Click event line.
Then click on the little button with 3 dots that will appear on that
line.
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those 2 lines write:

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
[RecordID]

The above assumes a [RecordID] field that is a Number Datatype.

If, however, [RecordID] is Text Datatype, then use:

DoCmd.OpenReport "ReportName", acViewPreview, ,"[RecordID] = '" &
[RecordID] & "'"

as the Where clause.

For clarity, the single and double quotes are..
"[RecordID] = ' " & [RecordID] & " ' "

Change [RecordID] to whatever the actual field name is that you are
using.

See VBA Help files for:
Where Clause + Restrict data to a subset of records'
 
R

rod_skeeter

Have a small employee database. Want to print ID cards for new hires.
report works fine for the whole file, but for one-at-a-time, it seems that
the report doesn't respect to filter - It wants to print all records
instead of the filtered table. Appreciate any help.

Your table should have a unique prime key field.
In my example it is named [RecordID].

Display your employee records on a form.
Add a command button.

On the command button's property sheet write
[Event Procedure]
on the Click event line.
Then click on the little button with 3 dots that will appear on that
line.
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those 2 lines write:

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
[RecordID]

The above assumes a [RecordID] field that is a Number Datatype.

If, however, [RecordID] is Text Datatype, then use:

DoCmd.OpenReport "ReportName", acViewPreview, ,"[RecordID] = '" &
[RecordID] & "'"

as the Where clause.

For clarity, the single and double quotes are..
"[RecordID] = ' " & [RecordID] & " ' "

Change [RecordID] to whatever the actual field name is that you are
using.

See VBA Help files for:
Where Clause + Restrict data to a subset of records'

I had a similiar issue with employee applications. Instead of all the
complex programming, I just duplicated the report and the query it was
based on.

Then I redefined my report (RPT#2 for reference) to be based on the
QRY#2. Then in QRY#2, for my field EmpID I put in the following in
the criteria box ( =[] ). No parentheses. Then when I am ready to
generate one application instead of ALL, I click the RPT#2 which then
asks for the parameter value (in this case the EmpID number (e.g.
225).

This way we only get the report/application or in your case ID Card
that you want for a specific employee.

Kindest Regards,

rod_skeeter
 
G

gg

Thanks, Fred - Works great.


fredg said:
Have a small employee database. Want to print ID cards for new hires.
report works fine for the whole file, but for one-at-a-time, it seems
that
the report doesn't respect to filter - It wants to print all records
instead of the filtered table. Appreciate any help.

gg

Your table should have a unique prime key field.
In my example it is named [RecordID].

Display your employee records on a form.
Add a command button.

On the command button's property sheet write
[Event Procedure]
on the Click event line.
Then click on the little button with 3 dots that will appear on that
line.
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those 2 lines write:

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
[RecordID]

The above assumes a [RecordID] field that is a Number Datatype.

If, however, [RecordID] is Text Datatype, then use:

DoCmd.OpenReport "ReportName", acViewPreview, ,"[RecordID] = '" &
[RecordID] & "'"

as the Where clause.

For clarity, the single and double quotes are..
"[RecordID] = ' " & [RecordID] & " ' "

Change [RecordID] to whatever the actual field name is that you are
using.

See VBA Help files for:
Where Clause + Restrict data to a subset of records'
 
E

Emelina Bumsquash

Hi Fred,
I found this useful piece of information which is relevant to what i want to
do as well. I've tried the code but with mine, it just opens the report as
usual - i was expecting some kind of dialogue box to ask you what [RecordID]
(or [StudyNumber], in my case) you want to filter by.

it may be the design of my report - it's all very complex by basically
there's a report with a number of subreports attached to queries. each of
these subreports returns the data for all the study numbers but i wanted a
filter as you open the report which means all the subreports (queries) filter
by the given study number and just show results for one person.

is this possible? thanks in advance for any help, Emma

fredg said:
Have a small employee database. Want to print ID cards for new hires.
report works fine for the whole file, but for one-at-a-time, it seems that
the report doesn't respect to filter - It wants to print all records
instead of the filtered table. Appreciate any help.

gg

Your table should have a unique prime key field.
In my example it is named [RecordID].

Display your employee records on a form.
Add a command button.

On the command button's property sheet write
[Event Procedure]
on the Click event line.
Then click on the little button with 3 dots that will appear on that
line.
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those 2 lines write:

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
[RecordID]

The above assumes a [RecordID] field that is a Number Datatype.

If, however, [RecordID] is Text Datatype, then use:

DoCmd.OpenReport "ReportName", acViewPreview, ,"[RecordID] = '" &
[RecordID] & "'"

as the Where clause.

For clarity, the single and double quotes are..
"[RecordID] = ' " & [RecordID] & " ' "

Change [RecordID] to whatever the actual field name is that you are
using.

See VBA Help files for:
Where Clause + Restrict data to a subset of records'
 

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