help with list

W

Will G

Hello, i am really new with access and i like to make a few adjustments to
my selection on a list. right at this moment, i have a multiselection list
and what it does with the code bellow is when i select a OrderNo, and print
result it will prints all OrderNos. to be more clear i will give an
example..........in the list row i have OrderNo, RequiredDate, CustomerID,
Comment, ProductID, Desc....and right now i have a criteria of OrderNo...

OrderNo | RequiredDate | CustomerID | Comment | ProductID| Desc
4001 4/6/07 MSC ANY A002
ANY
4001 4/5/07 VSC ANY1 A003
ANY
4001 4/5/07 VCC ANY A003
ANY
4444 4/6/07 MSC ANY A004
ANY

right now, if i select the first 4001 and 4444, i get all 4001s and 4444son
my report. i like to get just what i selected. do anyone know how to do
this....my code look like this.

strDoc = "rptProduction"
strLabel = "rptProductionLabel"
'Loop through the ItemsSelected in the list box.
If Me.sched.ItemsSelected.Count = 0 Then
Beep
MsgBox "no item selected ", 48
Exit Sub
End If

With Me.sched
For Each varItem In .ItemsSelected
If Not IsNull(varItem) Then
'Build up the filter from the bound column (hidden).
strWhere = strWhere & strDelim & .ItemData(varItem) &
strDelim & ","
'Build up the description from the text in the visible
column. See note 2.
'strDescrip = strDescrip & """" & .Column(1, varItem) & """, "
End If
Next
End With

lngLen = Len(strWhere) - 1
If lngLen > 0 Then
strWhere = "[OrderNo] IN (" & Left$(strWhere, lngLen) & ")"

lngLen = Len(strDescrip) - 4
If lngLen > 0 Then
'strDescrip = "Production Required: " & Left$(strDescrip, lngLen)
End If
End If

If CurrentProject.AllReports(strDoc).IsLoaded Then
DoCmd.close acReport, strDoc
End If

DoCmd.OpenReport strDoc, acViewPreview, WhereCondition:=strWhere,
OpenArgs:=strDescrip
 
H

hmadyson

It looks to me like your primary key is not just Orderno, but also required
date. In your strWhere you will need to give both. You can do this by looking
not only at the bound column in the list, but also the next column. So it
needs to end up showing (OrderNo = 4444 and RequiredDate=#4/6/07#) make sure
that you include the #s when putting a date in your where.

Please let me know if I can provide any more assistance.
 
W

Will G

Hello,

thanks for your response,
i have been trying to include RequiredDate to my bound columns but i just
dont know the code to do it i guess. i guess it should go something like

strWhere = "[OrderNo] IN (" & Left$(strWhere, lngLen) & ") AND,,,,,,"
can you help me out with that...i dont know where to go from there......and
can it please apply to the previous code bellow. thanks

--
need help


hmadyson said:
It looks to me like your primary key is not just Orderno, but also required
date. In your strWhere you will need to give both. You can do this by looking
not only at the bound column in the list, but also the next column. So it
needs to end up showing (OrderNo = 4444 and RequiredDate=#4/6/07#) make sure
that you include the #s when putting a date in your where.

Please let me know if I can provide any more assistance.

Will G said:
Hello, i am really new with access and i like to make a few adjustments to
my selection on a list. right at this moment, i have a multiselection list
and what it does with the code bellow is when i select a OrderNo, and print
result it will prints all OrderNos. to be more clear i will give an
example..........in the list row i have OrderNo, RequiredDate, CustomerID,
Comment, ProductID, Desc....and right now i have a criteria of OrderNo...

OrderNo | RequiredDate | CustomerID | Comment | ProductID| Desc
4001 4/6/07 MSC ANY A002
ANY
4001 4/5/07 VSC ANY1 A003
ANY
4001 4/5/07 VCC ANY A003
ANY
4444 4/6/07 MSC ANY A004
ANY

right now, if i select the first 4001 and 4444, i get all 4001s and 4444son
my report. i like to get just what i selected. do anyone know how to do
this....my code look like this.

strDoc = "rptProduction"
strLabel = "rptProductionLabel"
'Loop through the ItemsSelected in the list box.
If Me.sched.ItemsSelected.Count = 0 Then
Beep
MsgBox "no item selected ", 48
Exit Sub
End If

With Me.sched
For Each varItem In .ItemsSelected
If Not IsNull(varItem) Then
'Build up the filter from the bound column (hidden).
strWhere = strWhere & strDelim & .ItemData(varItem) &
strDelim & ","
'Build up the description from the text in the visible
column. See note 2.
'strDescrip = strDescrip & """" & .Column(1, varItem) & """, "
End If
Next
End With

lngLen = Len(strWhere) - 1
If lngLen > 0 Then
strWhere = "[OrderNo] IN (" & Left$(strWhere, lngLen) & ")"

lngLen = Len(strDescrip) - 4
If lngLen > 0 Then
'strDescrip = "Production Required: " & Left$(strDescrip, lngLen)
End If
End If

If CurrentProject.AllReports(strDoc).IsLoaded Then
DoCmd.close acReport, strDoc
End If

DoCmd.OpenReport strDoc, acViewPreview, WhereCondition:=strWhere,
OpenArgs:=strDescrip
 

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