Solved

print record from a userform

Posted on 2011-02-22
8
390 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
Comment Utility


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
Comment Utility
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
Comment Utility
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
 
LVL 1

Accepted Solution

by:
currentdb earned 0 total points
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Author Comment

by:currentdb
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Seems that what I wrote worked.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now