HELP PLEASE

G

Guest

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.
 
J

Jeff Boyce

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
 
G

Guest

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

Will G said:
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.
 
J

Jeff Boyce

Will

I'd suggest adding a breakpoint in the code so you can step through it, one
line at a time, until it breaks. That will help you narrow down the place
(and values) that trigger this.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Will G said:
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

Will G said:
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.
 
G

Guest

Hey Jeff,

i have tried to instead of printout according to [OrderQty], i placed any
number there and it prints fine....that means that it's the item [OrderQty]
that's not making it through. would it be the source of OrderQty, however
that table & query looks fine to me. the code i guess is fine too, but what
would i be doing wrong with the OrderQty stuff. would it be the form? the
buttons that triggers the print?, i tried other items that have numeric value
and it gives me the same error. example, i tried [Type] which is a number
field, it's not on the form but it goes from 3 to 10 and it gives me the same
error. however, [Type] is not on the report, i really dont know why is giving
me that error.
--
need help


Jeff Boyce said:
Will

I'd suggest adding a breakpoint in the code so you can step through it, one
line at a time, until it breaks. That will help you narrow down the place
(and values) that trigger this.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Will G said:
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.
 
J

Jeff Boyce

I can't be sure from your description... have you tried renaming the
field/control?

Also, if the value is on a form, is the form open when this runs?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Will G said:
Hey Jeff,

i have tried to instead of printout according to [OrderQty], i placed any
number there and it prints fine....that means that it's the item
[OrderQty]
that's not making it through. would it be the source of OrderQty, however
that table & query looks fine to me. the code i guess is fine too, but
what
would i be doing wrong with the OrderQty stuff. would it be the form? the
buttons that triggers the print?, i tried other items that have numeric
value
and it gives me the same error. example, i tried [Type] which is a number
field, it's not on the form but it goes from 3 to 10 and it gives me the
same
error. however, [Type] is not on the report, i really dont know why is
giving
me that error.
--
need help


Jeff Boyce said:
Will

I'd suggest adding a breakpoint in the code so you can step through it,
one
line at a time, until it breaks. That will help you narrow down the
place
(and values) that trigger this.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Will G said:
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


:

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.
 
G

Guest

Thanks for being patient with this Jeff,

yes, i item in showing on a form when funning this. it's on a list. however,
i tried to take it off and try to run it again and it gave the same problem.
I changed the name to it gave me the same problem. thanks for your help jeff
--
need help


Jeff Boyce said:
I can't be sure from your description... have you tried renaming the
field/control?

Also, if the value is on a form, is the form open when this runs?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Will G said:
Hey Jeff,

i have tried to instead of printout according to [OrderQty], i placed any
number there and it prints fine....that means that it's the item
[OrderQty]
that's not making it through. would it be the source of OrderQty, however
that table & query looks fine to me. the code i guess is fine too, but
what
would i be doing wrong with the OrderQty stuff. would it be the form? the
buttons that triggers the print?, i tried other items that have numeric
value
and it gives me the same error. example, i tried [Type] which is a number
field, it's not on the form but it goes from 3 to 10 and it gives me the
same
error. however, [Type] is not on the report, i really dont know why is
giving
me that error.
--
need help


Jeff Boyce said:
Will

I'd suggest adding a breakpoint in the code so you can step through it,
one
line at a time, until it breaks. That will help you narrow down the
place
(and values) that trigger this.

Regards

Jeff Boyce
Microsoft Office/Access MVP

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


:

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.
 
J

Jeff Boyce

Will

I looked back at your code and it appears that your strWHERE clause could
hold a number of selected items, separated by delimiters.

I'm not aware of a version of SQL syntax that would allow a statement that
looked like:

WHERE value1; value2; value3; ... valuen

You may want to take another look at WHERE clauses in SQL statements to come
up with one that works.

Here's one way to get an idea on that ... create a new query and add
multiple values to the selection criterion. You will probably either need
to use Value1 Or Value2 Or..., or In('Value1','Value2',...).

Regards

Jeff Boyce
Microsoft Office/Access MVP

Will G said:
Thanks for being patient with this Jeff,

yes, i item in showing on a form when funning this. it's on a list.
however,
i tried to take it off and try to run it again and it gave the same
problem.
I changed the name to it gave me the same problem. thanks for your help
jeff
--
need help


Jeff Boyce said:
I can't be sure from your description... have you tried renaming the
field/control?

Also, if the value is on a form, is the form open when this runs?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Will G said:
Hey Jeff,

i have tried to instead of printout according to [OrderQty], i placed
any
number there and it prints fine....that means that it's the item
[OrderQty]
that's not making it through. would it be the source of OrderQty,
however
that table & query looks fine to me. the code i guess is fine too, but
what
would i be doing wrong with the OrderQty stuff. would it be the form?
the
buttons that triggers the print?, i tried other items that have numeric
value
and it gives me the same error. example, i tried [Type] which is a
number
field, it's not on the form but it goes from 3 to 10 and it gives me
the
same
error. however, [Type] is not on the report, i really dont know why is
giving
me that error.
--
need help


:

Will

I'd suggest adding a breakpoint in the code so you can step through
it,
one
line at a time, until it breaks. That will help you narrow down the
place
(and values) that trigger this.

Regards

Jeff Boyce
Microsoft Office/Access MVP

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


:

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.
 

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