Print Single Record

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

What is the best way to print a single record. I want to do this as a sort
of receipt for a transaction that's being entered into the database.
I would like to add a control button that would either directly print this
record or preview it with the option to print.
I do not want to print the form page being displayed unless its possible to
print only the data fields and not the background, buttons and other
graphics.
I understand its best not to print a form directly but to use reports. With
the way this will be set up the operator would enter the data into a new
record and then have to immediately print out a receipt. Something tells me
that trying to create a report and then printing it out each time this has
to be done would get messy.
 
create the report *once*. then print it as necessary. add a "Print" button
to your form. add a macro or VBA procedure to the button's Click event. in
VBA, the code would be something like

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "ReportName", , , "FieldName = " _
& Me!ControlName

replace ReportName with the correct name of the report. replace FieldName
with the name of the primary key field in the table underlying the report.
replace ControlName with the name of the control that's bound to the primary
key field, in the form.

hth
 
Tina,
Im not sure i understand the last part about "replace ControlName with the
name of the control that's bound to the primary key field, in the form."
I have no control in the form that is bound to the primary key field. Can i
just designate another field as the primary key and then use it as the
reference for this last part?
Or are you saying that the print button is the control that needs to be
bound to the primary key field?
Real confused here. Is there a batter reverence to this on an Access site
somewhere?
Thanks
Mike
 
comments inline.

Mike said:
Tina,
Im not sure i understand the last part about "replace ControlName with the
name of the control that's bound to the primary key field, in the form."
I have no control in the form that is bound to the primary key field.

no problem, as long as the primary key field is included in the form's
RecordSource. (to verify that, just look at the Fields List in form Design
view. if the primary key field is listed there, you're fine.)
Can i
just designate another field as the primary key and then use it as the
reference for this last part?

no, no - don't change your table's primary key. just refer to the field
itself; the fields in the form's RecordSource are available in the VBA code,
so it's not a problem.

DoCmd.OpenReport "ReportName", , , "FieldName = " _
& Me!FieldName

the first FieldName is the name of the primary key field in the *report*'s
RecordSource. the second FieldName is the name of the primary key field in
the *form*'s RecordSource. in this case, presumably both the form and the
report are based on the same table, so the fieldname will be the same.

hth
Or are you saying that the print button is the control that needs to be
bound to the primary key field?

no, see above.
 
Tina,
Im running out of time with this database. Im hoping you will consider a
proposition id like to make and contact me at "timeisroATgmail.com"
Im no access Guru and i should have stuck to computer and network support.
Every time i go to work on this database my stomach is in knots and i have a
lot more to do.
Im hoping you will at least consider hearing me out.
Thanks
Mark
 
Back
Top