3 questions on report

G

Guest

how do i print a report that

1. record a time stamp in the table

2. put a counter on the report (e.g. Smith1 (printed 1x), Smith2 (printed
2x), etc...)

3. print an individual report by Primary key (number & date) in the forms
view (e.g. Smith is 999 & came on 1/1/01, select or type 999 and 1/1/01 and
print 1 report from forms view).

If this is an difficult task, please reference a database so I can use it as
a template.

Thanks!
Rookie
Using Access 2003
 
L

Larry Linson

Rookie said:
how do i print a report that

1. record a time stamp in the table

Reports do not update tables (at least until Access 2007). You can write
code to record information in appropriate tables. Do you really want to
timestamp every record in the table with the most recent report? If you
really feel compelled to do this, wouldn't a system table that included
information about each report, and a "run" would be recorded just once?
And, if you have worked in a business environment with shared printers that
sometimes crumple your output, would you want that recorded as "report was
run", or would you want to have the user make a record that the "report was
successfully executed" after retrieving and reviewing the output?
2. put a counter on the report (e.g. Smith1 (printed 1x), Smith2 (printed
2x), etc...)

You mean you want a record that includes a count of the times that
particular record was printed? Sounds to me as if you are going to burden
your system with more recordkeeping about what was done, when, than I have
seen on any system (short of systems which transferred actual funds, and
those didn't worry about when reports were done).
3. print an individual report by Primary key (number & date)
in the forms view (e.g. Smith is 999 & came on 1/1/01, select
or type 999 and 1/1/01 and print 1 report from forms view).

Assume you are displaying a Record in your form, and on the Form you have
displayed the MemberNum in Text Box txtMemberNum and TransDate in
txtTransDate (making up the key), and you select to print rptMemberTran, in
the code behind a command button (the basic code for which will be created
for you by the Command Button Wizard), there will be statements similar to:

Dim stDocName As String

stDocName = "rptMemberTran"
DoCmd.OpenReport stDocName, acPreview

along with some error handling code generated by the Wizard.

You modify the DoCmd.OpenReport to read:

DoCmd.OpenReport stDocName, acPreview,, "[MemberNum] = " &
Me.txtMemberNum & " And [TransDate] = #" & Me.txtTransDate & "#"

and that should print the Record for the MemberNum and TransDate entered on
the Form.

I recommend creating a Report for the purpose of reporting, not "printing
the form". I also recommend you display the report In Preview, so the user
can decide whether they have to make additional data changes before printing
the hard copy. Finally, my example assumes that the field MemberNum is, in
fact, a number as you said... if it is text using numeric characters for a
code then the modified DoCmd.OpenReport would be:

DoCmd.OpenReport stDocName, acPreview,, "[MemberNum] = """ &
Me.txtMemberNum & """ And [TransDate] = #" & Me.txtTransDate & "#"

The # is an Access convention to indicate a date.

I have described this for Access 2003, as you indicate you are using. If
someone else wants to use it for Access 2007, and it doesn't work for them,
then they will need to ask again and state that their question applies to
Access 2007.

Larry Linson
Microsoft Access MVP
 

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