Listbox Bound Column Problem

G

Guest

Hello All,

I have two cascading Listboxes that return a numeric value from a field in a
table. The code is as follows:

strSQL = "SELECT numOccSecKeyPK, strSecondaryKey " _
& "FROM tblOccSecKeys " _
& "WHERE numPrimaryKeyFK = " & Me.lboPrimOccToInclude & _
" ORDER BY strSecondaryKey"

Me.lboSecOccToInclude.RowSourceType = "Table/Query"
Me.lboSecOccToInclude.RowSource = strSQL

The above code works great. However, I need to change the bound column of
the first list box (lboPrimOccToInclude) as I need to return a text value,
instead of a numeric one. When I change the bound column to 3, from 1, the
first lisbox returns the correct text value. However, I get an error (Enter
parameter value) from the second listbox (lboSecOccToInclude). Hopefully I
explained my problem correctly :)

Regards
 
J

John Vinson

Hello All,

I have two cascading Listboxes that return a numeric value from a field in a
table. The code is as follows:

strSQL = "SELECT numOccSecKeyPK, strSecondaryKey " _
& "FROM tblOccSecKeys " _
& "WHERE numPrimaryKeyFK = " & Me.lboPrimOccToInclude & _
" ORDER BY strSecondaryKey"

Me.lboSecOccToInclude.RowSourceType = "Table/Query"
Me.lboSecOccToInclude.RowSource = strSQL

The above code works great. However, I need to change the bound column of
the first list box (lboPrimOccToInclude) as I need to return a text value,
instead of a numeric one. When I change the bound column to 3, from 1, the
first lisbox returns the correct text value. However, I get an error (Enter
parameter value) from the second listbox (lboSecOccToInclude). Hopefully I
explained my problem correctly :)

Regards

I'm a bit perplexed. It appears that the field that you're searching
for is a Number type field (numPrimaryKeyFK); why would you want to
search this field using a Text value?

If the field and the bound column are both in fact of Text type you
need to include the syntactically required quotemark delimiters:

strSQL = "SELECT numOccSecKeyPK, strSecondaryKey " _
& "FROM tblOccSecKeys " _
& "WHERE numPrimaryKeyFK = '" _
& Me.lboPrimOccToInclude & _
"' ORDER BY strSecondaryKey"

John W. Vinson[MVP]
 

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