Hey Jeff,
thanks for replying, the ' in from of the printout is because i had it
commented out, ignore that. the value under strWhere is the following; at
the
beginning of the code, i am just creating a record of each click and
items.
little further down is where the strWhere is ......thanks for your help
Dim varItem As Variant 'Selected items
Dim strWhere As String 'String to use as WhereCondition
Dim strDescrip As String 'Description of WhereCondition
Dim lngLen As Long 'Length of string
Dim strDelim As String 'Delimiter for this field type.
Dim strDoc As String 'Name of report to open.
Dim strLabel As String
Dim prm_sched As Control
Dim DBS As Database
Dim rst As Recordset
Set prm_sched = Me![sched]
If prm_sched.ItemsSelected.Count = 0 Then
Beep
MsgBox "no item selected ", 48
Exit Sub
End If
Set DBS = CodeDb
Set rst = DBS.OpenRecordset("SELECT * FROM POhistory")
'run through all selected items
For Each varItem In prm_sched.ItemsSelected
rst.AddNew
rst!OrderNo = prm_sched.Column(0)
rst!RequiredDate = prm_sched.Column(1)
rst!CustomerID = prm_sched.Column(2)
rst!ModelNumber = prm_sched.Column(3)
rst!Description = prm_sched.Column(4)
rst!OrderQty = prm_sched.Column(5)
rst!Comment = prm_sched.Column(6)
rst!Bfill = prm_sched.Column(7)
rst!Qfill = prm_sched.Column(8)
rst!Uphfill = prm_sched.Column(9)
rst!Ptfill = prm_sched.Column(10)
rst!Spring = prm_sched.Column(11)
rst!Label = prm_sched.Column(12)
rst!Size = prm_sched.Column(13)
rst!Needle = prm_sched.Column(14)
rst!Pattern = prm_sched.Column(15)
rst!Config = prm_sched.Column(16)
rst!Border = prm_sched.Column(17)
rst!Border = prm_sched.Column(18)
rst!FoamCore = prm_sched.Column(19)
rst!FoamEnc = prm_sched.Column(20)
rst.update
Next
strDoc = "rptProduction"
'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.
strDescrip = strDescrip & """" & .Column(1, varItem) & """,
"
End If
Next
End With
lngLen = Len(strWhere) - 1
If lngLen > 0 Then
strWhere = "[OrderNo] IN (" & Left$(strWhere, lngLen) & ")"
i am not even using this next part
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
DoCmd.PrintOut , , , , [OrderQty]
--
need help
Jeff Boyce said:
Will
What are the values of "strWhere" and "strDescrip"?
Why does the DoCmd.PrintOut line have an apostrophe before it?
Regards
Jeff Boyce
Microsoft Office/Access MVP
DoCmd.OpenReport "rptProduction", acViewPreview,
WhereCondition:=strWhere, OpenArgs:=strDescrip
'DoCmd.PrintOut , , , , [OrderQty]
WITH THE CODE ABOVE I AM TRYING TO PRINT THAT REPORT ACCORDING TO THE
[OrderQty] field found on the report. but what i get is an error saying
error 2465-- Microsoft Office Access can not find the '|' field
referred
to
in your expression
i dont have any '|' on the report and i dont know why is giving me that
error...does anyone, might have an idea, where would that come from? or
at
least where should look for that ''"|"" field thingy....help will be
appreciated.