?
Solved

print record from a userform

Posted on 2011-02-22
8
Medium Priority
?
415 Views
Last Modified: 2012-08-14
Hi all,

Is there a way to print a record inside a userform ?

I added a ''Print Record'' button to the userform. Still have to figure it out how to print from inside the form.

Any help would be appreciated.
Thanks
0
Comment
Question by:currentdb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 2

Expert Comment

by:jo_m
ID: 34952746


hello there


could you try  


Sub printform()
Docmd.Printout acselection,,,,1, true

End sub

Open in new window



This will print out a screen shot of the form


 hope this helps

tx

jo
0
 
LVL 2

Expert Comment

by:jo_m
ID: 34952876
Additionally you may wish to  find a specific  record before printing

so if you add a combo box to select the  record  to find  the record
and call it cmbFindRecord then put the code below on the after update  evebnt

 this will  navigate you to the selected record

As I don't know the  premise of your form  I selected  a generic record id  as the example
If you would like to,  or are able to upload your workbook I will be only too happy to review.


In case you need to filter the records down first.
 Here's one way to do it

Private Sub cmbFindRecord_AfterUpdate()

  ''Making a selection from this control filters the Orders form
  ''for orders by the selected Record
  
  'declare variables
  Dim sFilter As String

  'in this case, the ID is text so the ID value
  'needs to be wrapped in single quotes.
  sFilter = "[RecordID]= '" & Me.cmbFindRecordId & "'"

  'assign the filter value,and turn filtering on
  Me.Filter = sFilter
  Me.FilterOn = True
End Sub

Open in new window


tx jo
0
 
LVL 1

Author Comment

by:currentdb
ID: 34952882
Hi jo_m,

It does not work as I have this compile error ''Required object'' and it highlights this line Docmd.Printout acselection,,,,1, true

My button name is ''btnPrint''


0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Accepted Solution

by:
currentdb earned 0 total points
ID: 34952902
Hi jo_m,

Actually I do have a find record command and just needed to print the actual record that was found.

That's what the code looks like from the Print Button:

Private Sub btnPrint_Click()
    Docmd.PrintOut Command  acselection, , , , 1, True
End Sub

Open in new window


Maybe something is missing here..
0
 
LVL 1

Author Comment

by:currentdb
ID: 34953047
After some struggling, I came with this:

Private Sub btnPrint_Click()
  Me.PrintForm
End Sub

Open in new window


I made a quick test and this one does make a printout of the found record and the form itself.

Now I'm trying to add another button with the same purpose (to print), but it will have to print all records. Do you have an idea how to program this one ?
0
 
LVL 2

Expert Comment

by:jo_m
ID: 34957895
hello again

if I am not misunderstanding you ,  you would also like to print out all records from the worksheet
Activesheet.PrintOut   will do this

but you may need to set  print area
so to select your Range  (-   I used hypothetical  addresses as I don't know the size  of your worksheet.)

Range ("A1:  F9").select
Activesheet.pagesetup.printArea =  "$A$1:  $F$9"
Activesheet.PrintOut

hope this is what you need

tx

jo
0
 
LVL 1

Author Comment

by:currentdb
ID: 34960485
Hello again,

Your code will only print the active worksheet.

What about the one that will print from inside the userform ?

The one that I submitted at post ID 34953047 will print just the record that was found in the userform. Is there any way to print all records through the userform ?

For your info, the worksheet has 55 columns and the userform contains only 10, mostly used to get some quick info on a record (ex: address, name, mortgage, etc).

Tx
0
 
LVL 1

Author Closing Comment

by:currentdb
ID: 35081114
Seems that what I wrote worked.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question