Solved

print record from a userform

Posted on 2011-02-22
8
407 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
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!

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

738 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