List box

R

Richard

Hello, I have a list box that is populated with records created that day. If
I select one record or all records it makes no difference each record
outputs to its own report. I want the reverse of this, I want to select 1,2,
or 3 records and have them out put to the same report not individual
reports. Any help would be greatly appreciated thanks.
 
R

Richard

Is there a way to append records to a report?, I already have a good list
box and it works. When I multi-select the records they print on separate
reports I need re-work the code so my selection out puts to one report.
 
P

pietlinden

Richard said:
Is there a way to append records to a report?, I already have a good list
box and it works. When I multi-select the records they print on separate
reports I need re-work the code so my selection out puts to one report.

sounds like you're not creating the filter right. You should be ORing
the elements in the SelectedItems together, instead of opening a report
each time.

Dev has an example of how to do this:
http://www.mvps.org/access/reports/rpt0005.htm
 
D

Duane Hookom

I don't know what you mean by "append records to a report". The function
allows you to use a multi-select list box to filter a query which could be
the record source of a report.
 
R

Richard

Explaining my project is almost as frustrating as working on it...I've given
up on it several times now...
Humbling experience...
 
G

Guest

Hi,

The code I am using for my Multi-select list box was copied from
"programming Access for dummys"

Option Compare Database
Option Explicit
Function SelectAllOrders()
Dim I, K
For I = 1 To Me.UnverifiedOrders.ListCount - 1
Me.UnverifiedOrders.Selected(I) = True
Next
UpdateCount
End Function
Function UnSelectAllOrders()
Dim I, K
For I = 1 To Me.UnverifiedOrders.ListCount - 1
Me.UnverifiedOrders.Selected(I) = False
Next
UpdateCount
End Function
Private Sub Form_Load()
With Me.UnverifiedOrders
.RowSource = _
"SELECT orderid, DateValue(OrderDate) AS [Date] ," & _
"shiplast & ', ' & shipfirst As [Ship To], " & _
"shipcity & ', ' & shipstate & ' ' & shipzip AS [Location], " & _
"Ordertotal as Total, Items FROM Orders " & _
"WHERE not paymentverified ORDER BY orderid DESC"
.ColumnCount = 6
.ColumnWidths = ".5 in;.75 in;1.5 in;1.75 in;.5 in; .5 in;"
.ColumnHeads = True
End With

End Sub

Private Sub PrintButton_Click()
Dim OID, RC
For Each OID In Me.UnverifiedOrders.ItemsSelected
RC = SysCmd(acSysCmdSetStatus, _
"Printing Invoice for order #" & _
Me.UnverifiedOrders.Column(0, OID) & _
" " & Me.UnverifiedOrders.Column(2, OID))
DoCmd.OpenReport _
ReportName:="Invoice", _
view:=acViewNormal, _
wherecondition:="Orderid = " & Me.UnverifiedOrders.Column(0, OID)
Next
RC = SysCmd(acSysCmdClearStatus)
End Sub

Private Sub UnverifiedOrders_AfterUpdate()
UpdateCount
End Sub

Sub UpdateCount()
Me.Caption = "Print " & Me.UnverifiedOrders.ItemsSelected.Count & "
orders selected"
End Sub
Private Sub Command11_Click()
DoCmd.Close
End Sub

I was hoping to tweak this so all my selections would print onto one report..
Thanks again.
 
D

Duane Hookom

Looking at the code posted in another thread, it seems you aren't using the
sample generic function that I suggested.
 
R

Richard

Duane,

This was the original code I was trying to adapt to my project, I did look
at your sample function, but I only have a month of access experience its
like learning Chinese...eventually this will sink in but for now I am pretty
much lost. Much thanks to you and J.Goddard, Pietlinden.
 
J

J. Goddard

There's your problem. The docmd.openreport line is inside the for each
.... next loop.

Use the loop to build up the wherecondition string, then run the report
afterwards.

John

Hi,

The code I am using for my Multi-select list box was copied from
"programming Access for dummys"

Option Compare Database
Option Explicit
Function SelectAllOrders()
Dim I, K
For I = 1 To Me.UnverifiedOrders.ListCount - 1
Me.UnverifiedOrders.Selected(I) = True
Next
UpdateCount
End Function
Function UnSelectAllOrders()
Dim I, K
For I = 1 To Me.UnverifiedOrders.ListCount - 1
Me.UnverifiedOrders.Selected(I) = False
Next
UpdateCount
End Function
Private Sub Form_Load()
With Me.UnverifiedOrders
.RowSource = _
"SELECT orderid, DateValue(OrderDate) AS [Date] ," & _
"shiplast & ', ' & shipfirst As [Ship To], " & _
"shipcity & ', ' & shipstate & ' ' & shipzip AS [Location], " & _
"Ordertotal as Total, Items FROM Orders " & _
"WHERE not paymentverified ORDER BY orderid DESC"
.ColumnCount = 6
.ColumnWidths = ".5 in;.75 in;1.5 in;1.75 in;.5 in; .5 in;"
.ColumnHeads = True
End With

End Sub

Private Sub PrintButton_Click()
Dim OID, RC
For Each OID In Me.UnverifiedOrders.ItemsSelected
RC = SysCmd(acSysCmdSetStatus, _
"Printing Invoice for order #" & _
Me.UnverifiedOrders.Column(0, OID) & _
" " & Me.UnverifiedOrders.Column(2, OID))
DoCmd.OpenReport _
ReportName:="Invoice", _
view:=acViewNormal, _
wherecondition:="Orderid = " & Me.UnverifiedOrders.Column(0, OID)
Next
RC = SysCmd(acSysCmdClearStatus)
End Sub

Private Sub UnverifiedOrders_AfterUpdate()
UpdateCount
End Sub

Sub UpdateCount()
Me.Caption = "Print " & Me.UnverifiedOrders.ItemsSelected.Count & "
orders selected"
End Sub
Private Sub Command11_Click()
DoCmd.Close
End Sub

I was hoping to tweak this so all my selections would print onto one report..
Thanks again.

:

Hi -

Can you post the code that generates the report?

John


Richard wrote:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top