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 / Forms / May 2008

Tip: Looking for answers? Try searching our database.

Command button to Print/View Customer

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
teelee - 02 May 2008 23:39 GMT
I have a form named Orders by Customer that has a subform with all the
customer's orders and I want to add a command button on the bottom so that
when an individual customer is showing along with all their information I can
print/view that info for that customer showing. Is there a way I can do this?

Thanks in Advance
Damon Heron - 03 May 2008 01:26 GMT
Design the report for Customer Orders using the report wizard.  Then, add
your command button to the form and use the
openreport method to open for the customer that is current.  See VB Help for
the openreport method use.

Damon

>I have a form named Orders by Customer that has a subform with all the
> customer's orders and I want to add a command button on the bottom so that
[quoted text clipped - 4 lines]
>
> Thanks in Advance
teelee - 03 May 2008 14:45 GMT
I already have a report with customers orders and added the command button,
but when I click on it I get all the customers showing on the report. I only
need the customer that is showing in the subform.

Thanks

> Design the report for Customer Orders using the report wizard.  Then, add
> your command button to the form and use the
[quoted text clipped - 11 lines]
> >
> > Thanks in Advance
Damon Heron - 03 May 2008 18:14 GMT
Okay, On the command button's properties, you will find the click event.
click on the (...) dots to go to the VB Editor.  Add this code,
substituting your field and report names as needed..
Private Sub Command1_Click() ' your button may have a different name

DoCmd.OpenReport "Report1", acViewPreview, , "CustomerID= " & Text0,
acWindowNormal

'(in this case, the field Text0 holds the CustomerID on your form.
"CustomerID" is the name of the field in the table and on your 'report.)
This restricts the report to the customerID of your current form.

End Sub

Damon
>I already have a report with customers orders and added the command button,
> but when I click on it I get all the customers showing on the report. I
[quoted text clipped - 21 lines]
>> >
>> > Thanks in Advance
teelee - 04 May 2008 23:43 GMT
Ok this is what I have: Private Sub Preview_Report_Click()
DoCmd.OpenReport "Rpt Customer"
acViewPreview , , "CustomerID=" & Text0, acWindowNormal

End Sub
and this is the error message I'm getting: Compile error
                               Invalid use of Property
Any Suggestions of what I'm doing wrong?

Thanks

DoCmd.OpenReport "Rpt Customer"
acViewPreview , , "CustomerID=" & Text0, acWindowNormal

End Sub

> Okay, On the command button's properties, you will find the click event.
> click on the (...) dots to go to the VB Editor.  Add this code,
[quoted text clipped - 36 lines]
> >> >
> >> > Thanks in Advance
John W. Vinson - 05 May 2008 00:54 GMT
>Ok this is what I have: Private Sub Preview_Report_Click()
>DoCmd.OpenReport "Rpt Customer"
[quoted text clipped - 9 lines]
>DoCmd.OpenReport "Rpt Customer"
>acViewPreview , , "CustomerID=" & Text0, acWindowNormal

If you have a textbox named Text0 on the form, change Text0 in the above to

Me!Text0

That's a default name for a control, but it's a really bad name from a
usability and documentation standpoint; consider renaming the control and
using the new name in the Me! expression.
Signature


            John W. Vinson [MVP]

Damon Heron - 05 May 2008 04:24 GMT
As I said: "substituting your field and report names as needed"-  do you
really have a "text0" textbox with the recordsource set to CustomerID?
If not, change the line to your textbox name. and take John's advice and
include the "me." although it will work without it.
Also, the line beginning "DoCmd."  should all be on one line, hopefully that
is what you did, sometimes its hard to tell with News posts.

Damon

> Ok this is what I have: Private Sub Preview_Report_Click()
> DoCmd.OpenReport "Rpt Customer"
[quoted text clipped - 59 lines]
>> >> >
>> >> > Thanks in Advance
 
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.