Solved

print record from a userform

Posted on 2011-02-22
8
397 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
  • 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel User Form VBA Help 18 32
Office 2016 without internet 6 38
Alphabetical Order for Letters 2 21
Excl VBA Find last column in disjointed range selection 18 22
INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

772 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