B
bigwillno2 via AccessMonster.com
Hello, if anyone can help with this will be greatly appreciated.
i have a big problem with my code and list box.
Query: qrProduction............ModelNumber, OrderNo, RequiredDate, CustomerID,
Desc, OrderQty, Spring, Border, Panel, So on......... for every Model Number
there is a Spring, Border, Panel so on...this are the items that we Order
from Vendors.
Goal: to produce a Purchase Order for a company.
Listbox: sched has a rowsource of qrProduction
OrderNo| RequiredDate| CustomerID | ModelNumber | Desc | OrderQty
011 04/27/07 BBM G200M ANY
3
011 04/27/07 BBM W100M ANY
2
012 04/27/07 WMD G200M ANY
3
Report: PO has a rowsource of qrProduction
i am not very experienced in this, but i gathered some code to have the
multiselect list work and produce that report. i currently have OrderNo, an
item in the listbox, as the only criteria to the report printout. i like to
have the criteria by every line selection, and not an item only.
Problem: i know that code bellow is set to have just OrderNo as the criteria
strWhere, i am having difficulties having the whole line being the criteria.
i want it by selection, not by OrderNo. Can anyone help with this.....?
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
'Remove trailing comma. Add field name, IN operator, and brackets.
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 "rptProduction", acViewPreview, WhereCondition:=strWhere,
OpenArgs:=strDescrip
Resp = MsgBox("Print??????", vbYesNo)
If Resp = vbYes Then
DoCmd.PrintOut
Else
DoCmd.OpenReport "rptProduction", acViewPreview, WhereCondition:=strWhere,
OpenArgs:=strDescrip
End If
i have a big problem with my code and list box.
Query: qrProduction............ModelNumber, OrderNo, RequiredDate, CustomerID,
Desc, OrderQty, Spring, Border, Panel, So on......... for every Model Number
there is a Spring, Border, Panel so on...this are the items that we Order
from Vendors.
Goal: to produce a Purchase Order for a company.
Listbox: sched has a rowsource of qrProduction
OrderNo| RequiredDate| CustomerID | ModelNumber | Desc | OrderQty
011 04/27/07 BBM G200M ANY
3
011 04/27/07 BBM W100M ANY
2
012 04/27/07 WMD G200M ANY
3
Report: PO has a rowsource of qrProduction
i am not very experienced in this, but i gathered some code to have the
multiselect list work and produce that report. i currently have OrderNo, an
item in the listbox, as the only criteria to the report printout. i like to
have the criteria by every line selection, and not an item only.
Problem: i know that code bellow is set to have just OrderNo as the criteria
strWhere, i am having difficulties having the whole line being the criteria.
i want it by selection, not by OrderNo. Can anyone help with this.....?
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
'Remove trailing comma. Add field name, IN operator, and brackets.
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 "rptProduction", acViewPreview, WhereCondition:=strWhere,
OpenArgs:=strDescrip
Resp = MsgBox("Print??????", vbYesNo)
If Resp = vbYes Then
DoCmd.PrintOut
Else
DoCmd.OpenReport "rptProduction", acViewPreview, WhereCondition:=strWhere,
OpenArgs:=strDescrip
End If