Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Print form - Current record

Posted on 2009-07-13
25
Medium Priority
?
2,623 Views
Last Modified: 2013-11-28
Hi Guys

Is there a way to print out the active form, current record, without using reports
I add a button in the design view which creates a macro, but it prints out the form but all the records, i need to print the form with the current record

Please advice
0
Comment
Question by:titorober23
[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
  • 10
  • 8
  • 3
25 Comments
 
LVL 75
ID: 24842891
You would have to Filter the form to the desired record first.  You can easily do that with the built in Right Click menus ...  in this case, Filter By Selection >> Print >> Right click and Remove Filter/Sort.

mx
0
 

Author Comment

by:titorober23
ID: 24842910
is there a way to put that in code behind a button
0
 

Author Comment

by:titorober23
ID: 24842962
in this particular case it is already filtered because i am trying to print a subform, which contains all the records associated with the main form, but when i hit print it prints all the records in the subform for all the records in the main form, i need to print current form view with current record information
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 800 total points
ID: 24842999
Actually ... try this:

Private Sub btnPrint_Click()

    DoCmd.PrintOut acSelection

End Sub

but it appears to directly to the printer ... no preview.  I've never used the PrintOut command before

mx
0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 800 total points
ID: 24843027
Or something like this:

Private Sub btnPrint_Click()
   
    Me.Filter = "[ID] = " & Me![ID]
    Me.FilterOn = True
    DoCmd.RunCommand acCmdPrintPreview
    DoCmd.RunCommand acCmdRemoveFilterSort
   
End Sub

where ID is the Primary Key name of the main table.

mx
0
 
LVL 75
ID: 24843041
OK ... forget this line:

DoCmd.RunCommand acCmdRemoveFilterSort   ' that will cause an error.

mx
0
 

Author Comment

by:titorober23
ID: 24843066
No they did not work
thanks
0
 
LVL 75
ID: 24843068
If you are already on just one record ... this should work:

Private Sub btnPrint_Click()
   
    'Me.Filter = "[ID] = " & Me![ID]
    'Me.FilterOn = True
    DoCmd.RunCommand acCmdPrintPreview

End Sub


it does for me.

mx
0
 
LVL 75
ID: 24843081
what exactly is happening ?

mx
0
 

Author Comment

by:titorober23
ID: 24843095
when running it is taking me to code that i ahve in the main form On_resize event
0
 
LVL 75
ID: 24843115
not following ?

mx
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24847918
titorober23,

1. The forms are not really meant to be printed, because of their graphical nature.

2. <print out the active form, current record, without using reports>
What is the reason why a report is unacceptable?
It is a faily common practice to print out a report synchronized to the selected (current) Form record.

3. How are you wanting to print the current record?

In other words, you need to be specific.
Please post a screenshot of your form.
Then post an example of the *exact* "printout" you are expecting.

Thanks.

JeffCoachman
0
 

Author Comment

by:titorober23
ID: 24849556
weel i was thinking it was easier and faster just to print current record view, instead of creating a report and try to replicate the form design
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24850776
Then I see no reason why the snippet MX posted wouldn't work for you:
    DoCmd.PrintOut acSelection

Can you clearly define what you mean by "they did not work"?
error message?
Crash?
Wrong Printout?
...ect

That code works fine for me...

;-)

JeffCoachman
0
 

Author Comment

by:titorober23
ID: 24850879
Well they were sending to the printer all the records, it actually did the same thing that my original macro

I am trying to print out the currrent subform
0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 800 total points
ID: 24851493
Here:  http:#a24843068 you said you were already on *just* the current record, ie already filtered ... so ... there is no reason this would not work:

Private Sub btnPrint_Click()  
    DoCmd.RunCommand acCmdPrintPreview
End Sub

OR ... to filter on just the current record:

Private Sub btnPrint_Click()
   
    Me.Filter = "[ID] = " & Me![ID]
    Me.FilterOn = True
    DoCmd.RunCommand acCmdPrintPreview
   
End Sub

I'm seeing this work right now in front of me ...

mx
0
 

Author Comment

by:titorober23
ID: 24851743
i guess what happens is the form that i am trying to print is a subform of another subform, where the main form is a switchboard that contains and loads different forms, when it tries to print, it activate the On_Resize event of the main switchboard form
0
 
LVL 75
ID: 24851801
"the form that i am trying to print is a subform of another subform,"

Ahh so ... well, ok ... that ... is going to be more complicated for sure. Whereas I do have cases where a form can be printed for convenience ...  forms with subforms are another matter.  As Jeff suggested ... maybe you should consider creating a report in this case.  Believe me ... wherein you *can* print forms (and I do it) ... there are many anomalies for sure.

mx
0
 

Author Comment

by:titorober23
ID: 24851830
yes i already design a report for it

thanks a lot
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24853855
mbizup.

FWIW,

MX did give this his all by trying to give the asker exactly what they were after, (Printing from the form) by posting no less than 3 distict alternatives.

(Even I would not have gone that far)
;-)

I have no issue with MX being awarded all the points.
Suggesting a report is something MX would have eventually suggested on his own anyway.
;-)

I will be fine with whatever you decide.

;-)

Jeff
0
 
LVL 75
ID: 24854277
split is np.

mx
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

721 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