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 / February 2005

Tip: Looking for answers? Try searching our database.

vba coding

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jessica - 14 Feb 2005 20:03 GMT
Hi Everyone,

I want to set up a form where the user selects a UPC number or many UPC
numbers from a list box and then clicks on the button where a certain
report will be previewed or printed of the  information of just the UPC
numbers that were selected. I will have over 500 UPC numbers in my table
and probably 5 different reports. The thing is, can I have it so that a
UPC range is directed to a certain report. i.e upc between the range of
1111 to 3333 will be printed using report 1, 4444 to 6666 will be
printed using report 2, and everything else not in these ranges will be
printed using report 3.

Thanks,
Jess
Rob Parker - 15 Feb 2005 07:36 GMT
The following code should help you:

Private Sub cmdOpenReports_Click()
 Dim varSelectedUPC As Variant
 Dim lngUPC as Long

 For Each varSelectedUPC In lstUPC.ItemsSelected
   lngUPC = lstUPC.ItemData(varSelectedUPC)
   Select Case lngUPC
     Case 1111 to 3333
       DoCmd.OpenReport "report1", acViewPreview, ,"UPC = " & lngUPC
'preview report; change to acViewormal to print immediately
     Case 4444 to 6666
         DoCmd.OpenReport "report2", acViewPreview, ,"UPC = " & lngUPC
     Case Else

         DoCmd.OpenReport "report3", acViewPreview, ,"UPC = " & lngUPC
   End Select
 Next varSelectedUPC
End Sub

This assumes that your list box is named lstUPC (multi-select, with UPC
being the bound column), that your reports have a recordset which includes
UPC (which is a number), and that you want a separate report
previewed/printed for each UPC (rather than a single report for all UPCs
within a range).  You should probably add error checking/trapping to cope
with no data, or ...   It's up to you where you take this.

BTW, a list box with over 500 items seems a little user-unfriendly ;-)

HTH,

Rob

> Hi Everyone,
>
[quoted text clipped - 10 lines]
> Thanks,
> Jess
Jessica - 15 Feb 2005 15:57 GMT
Thank you so much Rob I will try this when I get home tonight. I thought
that maybe what I wanted was asking too much but I guess not.

Thanks a million,
Jess

> The following code should help you:
>
[quoted text clipped - 44 lines]
>>Thanks,
>>Jess
 
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.