Databound combo generates list of a second databound combo

jpetiot
06-09-2002, 12:40 PM
Hi all,

I am looking for a solution to the following scenario: I create a combo 'market1' which is databound to DataMarket1, let's say this combo has 10 items, I would like that when the user selects one item 'Computers and telecoms' it generates the list of combo 'market2' with item1 'computers' and item2 'telecoms'.

I tried using a table which has both columns 'market1' and 'market2' as follows:

ID - market1 - market 2
1 - computers and telecoms - computers
2 - computers and telecoms - telecoms

I tried to use the following SQL statement for DataMarket2:

SQLstrActivite2 = "SELECT * FROM [CMBSRC_Market2] WHERE Market1=" & "'" & DBCmbMarkete1.BoundText & "'"

For some reason this does not work and I keep getting error messages.

Some light would be welcome on this scenario...

Thanks,
Julien

joe77s
06-09-2002, 10:14 PM
SQLstrActivite2 = "SELECT * FROM [CMBSRC_Market2] WHERE Market1=" & "'" & DBCmbMarkete1.BoundText & "'"



your code should be like this :

SQLstrActivite2 = "SELECT * FROM [CMBSRC_Market2] WHERE Market1=' " & DBCmbMarkete1.BoundText & " ' "

jpetiot
06-10-2002, 01:59 AM
It tells me 'data type mismatch in criteria expression' in VB when I run the app.

The strange thing is that when I run the SQL statement in Visdata it works fine with a parameter 1 instead of DBCmbMarket1.BoundText.

If I use a parameter 1 in VB I get the same 'data type mismatch' error message.

Julien

dcl3500
06-10-2002, 02:09 AM
Is the column Market1 a numeric datatype? If so, eliminate the single quote marks from Joe77's example and try that.

jpetiot
06-10-2002, 10:56 AM
Indeed DBCmbMarket1 is a databound dropdown and therefore contains a numeric value which is translated to a text value: the user sees text such as "Computers & Telecoms" but the value is 1.

If I remove the single quotes there is an additional error message which is: Too few parameters. Expected 1.

Julien

dcl3500
06-10-2002, 11:04 AM
Sounds like a typo in a field or table name now. Double check that all are spelled correctly.

jpetiot
06-10-2002, 11:52 AM
Yes, I used: SQLstrMarket2 = "SELECT * FROM [CMBSRC_Market2] WHERE Market1=" & DBCmbMarket1.BoundText & ""

Again, it works in Visdata with a numeric value.

Julien

dcl3500
06-10-2002, 12:01 PM
Well you could try using cInt() or cLng() on the DBCmbMarket1.BoundText and see if that takes care of it for you.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum