Print a record from a form

  • Thread starter Thread starter Brandon
  • Start date Start date
B

Brandon

Hi,

I'm a newbie to Microsoft Access. Can someone help me and tell me how I
can print the current record from a form.

Brandon
 
Hi,

I'm a newbie to Microsoft Access. Can someone help me and tell me how I
can print the current record from a form.

Brandon

Your table should have a unique prime key field.

If so, add a command button to the form.
Code the command button's Click event:

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

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

If [RecordID] is Text Datatype, then use:

"[RecordID] = '" & [RecordID] & "'"

as the Where clause.

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

See Access Help files for:
Where Clause + Restrict data to a subset of records'
 
Hi Fred,

I copied the code that you sent me and I inputed all of my information.
It's not working. My form name is called frmLIHEmployee and the primary
key is #. Can you please help me out.

Thank you
 
Hi Fred,

I copied the code into my Access code area and when I put in my
information there's a pop-up that says compile error. Did code it
right? My form is called frmLIHEmployee and my primary key field is #.

Nicole
 
fred's answer assumes that you're wanting to print a *report* which contains
the data from the current record on the form. if you're not trying to print
a report, you should be - forms are for displaying/editing data from tables,
and reports are for printing data from tables.

use fred's answer to print your report, substituting the "real" report and
field names in the code.

hth
 
Back
Top