Print a FORM view not a Report

PattyS

Registered User.
Local time
Today, 02:11
Joined
Jun 20, 2006
Messages
39
I am trying to put a print current record code behind a button on my form
this code prints ALL of the records
I want just the record that is currently being viewed in Form View
Code
DoCmd.SelectObject acForm, "Legal Process"
DoCmd.PrintOut acPages, 1,1

be advised!
this form record source is a query
CasePlainDefend

which is a combination of two tables
tblCase Primary key= CaseID
tblPlain_Defend Primary key = IDPlainDefend
Both autonumbers
these PK are not needed in the form view so they were not placed there
the relationship is between
CaseNo and PLCaseNo one to many No integrity
the CaseNo is text and is different in every case and used to identify
the plaintiffs and defendants in tblPlainDefend

can you help me print the form? is it possible?
and NO I dont want a Report


i
 
I put a btton on a form and used your basic Printout code

Private Sub Command23_Click()
DoCmd.PrintOut acPages, 1, 1

End Sub

but it printed only the first record --NOT The Current record????
 
Last edited:
I used this code behind a button

DoCmd.OpenForm "frmrptCurrentRecordInvoice", acPreview, , "[InvoiceID]= forms!frmInvoicing![InvoiceID]"
DoCmd.PrintOut
DoCmd.Close
 
jdraw
what i meant was
print the form that presently is open (because its the form with the print button) with the current record in view or current record
 
ok, I did boyh the codes post 2 and post 3 (changing the names)
both produced all of the records being printed or previewed
 
Yes I figured you wanted to print the form with the values in the current record.

I keep getting the first record in the recordset regardless of what is current.

I'm not at my home machine. I have no printer. I'm trying to priiint to a pdf driver PDF Creator, but I'm having issues. I tried Sketchin's approach, but I'm still getting the first record.

I have even set it up a little differently to force a single record, but I think my issues are with PDF Creator.

Code:
Private Sub Command22_Click()
Dim holdEmpId As Long
holdEmpId = Me.EmpId
Dim sFltr As String
sFltr = """" & "[EmpID]=" & holdEmpId & """"
Debug.Print sFltr
Debug.Print "Attempting to print record for Emp ID  " & Me.EmpId
DoCmd.OpenForm "frmEmployee_SortAZ_orRevert", acPreview, sFltr
DoCmd.PrintOut ' acPages, 1, 1

End Sub

I still end up with the first record in the underlying dataset???

Even though my filter criteria is
"[EmpID]=3"
Attempting to print record for Emp ID 3
 
Oh thats right...I made a special form that opens when you click that button. You just have to put this:
"[InvoiceID]= forms!frmInvoicing![InvoiceID]"
in the filter portion of the form properties.
 
Oh thats right...I made a special form that opens when you click that button. You just have to put this:
"[InvoiceID]= forms!frmInvoicing![InvoiceID]"
in the filter portion of the form properties.

I think I did exactly what you are suggesting, but I'm just getting the first record in the underlying recordset.

You do get the specific record right?
 
Yes, I get the specific record. I do this same thing to email the record to whoever I am invoicing.
 
PattyS,

I don't understand how you can get all records printed.

Sketchin's code should restrict you to 1 record.

Can you post a copy of your database?
 
jdraw, I cant upload right now but just a basic question
does the field on the record that you point your code to , does that have
to be the primary key of the record or can you point to another field that is also unique
 
You should be able to point to any field(s) in the recordset you want, and have the criteria restrict to 1 record.
 
You will not have any control over printing the form itself, so a report will be the only way that you can regain any control over exactly what is printed.

The Printout Method (VB) might work.
I foud this on an old post (2006)
 

Users who are viewing this thread

Back
Top Bottom