HEPL with Open report from List Box String

B

boris

I get error when opening a report from a list box, I have try making a
query def and it works, I also have work with the following sub for a
numeric field.

Case "frmContacInfo_Prod"

For Each varSelected In Me!list.ItemsSelected
strSQL = strSQL & Me!list.ItemData(varSelected) & ","
Next varSelected
If strSQL <> "" Then
strSQL = "[PubID] IN (" & Left(strSQL, Len(strSQL) - 1) &
")"
DoCmd.OpenReport "frmContacInfo_prod", acPreview, , strSQL
End If
WHEN [PUBID] IS A NUMBER FIELD IT WORK FINE!
BUT IN THIS CASE THE PUBID FIELD IS A TEXT

PubID is Column(0) in the list box.

Have read about double quotes, but I keep trying in diferent place and
it does not work, I get error of type mismatch an sooo on
Can someboby help????
 
C

Chris L via AccessMonster.com

strSQL = strSQL & """" & Me!list.ItemData(varSelected) & ""","

I get error when opening a report from a list box, I have try making a
query def and it works, I also have work with the following sub for a
numeric field.

Case "frmContacInfo_Prod"

For Each varSelected In Me!list.ItemsSelected
strSQL = strSQL & Me!list.ItemData(varSelected) & ","
Next varSelected
If strSQL <> "" Then
strSQL = "[PubID] IN (" & Left(strSQL, Len(strSQL) - 1) &
")"
DoCmd.OpenReport "frmContacInfo_prod", acPreview, , strSQL
End If
WHEN [PUBID] IS A NUMBER FIELD IT WORK FINE!
BUT IN THIS CASE THE PUBID FIELD IS A TEXT

PubID is Column(0) in the list box.

Have read about double quotes, but I keep trying in diferent place and
it does not work, I get error of type mismatch an sooo on
Can someboby help????
 

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