Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / January 2005

Tip: Looking for answers? Try searching our database.

Print current form only

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tvh - 06 Jan 2005 17:47 GMT
I've placed a "Print Invoice" command button on the bottom of a form, but
when I select the button, ALL of the invoices are printed.  How can I just
print the current form that I'm working with?
Here's the current print procedure:

***************************
Private Sub PrintInvoice_Click()
On Error GoTo Err_PrintInvoice_Click

   Dim stDocName As String

   stDocName = "Invoice"
   DoCmd.OpenReport stDocName, acNormal

Exit_PrintInvoice_Click:
   Exit Sub

Err_PrintInvoice_Click:
   MsgBox Err.Description
   Resume Exit_PrintInvoice_Click
   
End Sub
***************************
Paul Doree - 06 Jan 2005 18:14 GMT
Hi,

The following will do the job (it picks up your invoiceID from your form and
passes it to the report, printing only that record displaying on the
screen):

       Dim strDocName As String
       Dim strWhere As String
       strDocName = "Invoice"
       strWhere = "[InvoiceID]=" & Me!InvoiceID
       DoCmd.OpenReport strDocName, acViewNormal, , strWhere

> I've placed a "Print Invoice" command button on the bottom of a form, but
> when I select the button, ALL of the invoices are printed.  How can I just
[quoted text clipped - 19 lines]
> End Sub
> ***************************
Albert D. Kallal - 07 Jan 2005 14:16 GMT
> Hi,
>
[quoted text clipped - 7 lines]
>        strWhere = "[InvoiceID]=" & Me!InvoiceID
>        DoCmd.OpenReport strDocName, acViewNormal, , strWhere

The above you have is 100%, however, if the user changes some data and hits
print, those changes
have NOT yet been saved, and will not appear in the invoice.

You nee add the following one line to force (write) the data to disk so the
report will see this data:

>        Dim strDocName As String
>        Dim strWhere As String
me.Refresh                  <---- add this line to force a disk write....
>        strDocName = "Invoice"
>        strWhere = "[InvoiceID]=" & Me!InvoiceID
>        DoCmd.OpenReport strDocName, acViewNormal, , strWhere

Signature

Albert D. Kallal   (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@msn.com
http://www.attcanada.net/~kallal.msn

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.