PDA

Click to See Complete Forum and Search --> : Strange problem with dbCombo.BoundText


Michael Kizer
Sep 14th, 2000, 06:39 PM
Here's a weird one that was driving me crazy today...

I have a dbCombo bound to a data control (Data1) for a table that is just basically just an ID & Desc. The dbCombo.boundcolumn is set to the ID and the dbCombo.listfield is set to the Desc.
In the Change event I do this:
Data2.RecordSource = "select * from DifferentTable where ID_Field=" & dbCombo.BoundText
Data2.Refresh

Now, this works fine when I run the app from the IDE, but if I put a break point on the Data2.RecordSource line, the value of BoundText contains the value of the Desc field (which of course causes the line to fail). Strange...

I am running VB6 SP4

Johannes Schade
Sep 15th, 2000, 02:07 AM
I understand your binding to the Data Control "Data1", that is the ordinary thing. However what do you try to do with the Change event and the Data2?
I would guess the reason why you did not get a reply earlier is that nobody understood what you actually want to do. Do you want to reload the same combo box from a different source, when the user has done a first selection?

Michael Kizer
Sep 15th, 2000, 09:25 AM
I can elaborate...
the dbCombo in question is populated by Data1. Once the user chooses an item in that combo, I use that selection as the where clause argument for the select statement in Data2's RecordSource. I then use Data2 to populate a grid. THe user could at anytime go back up to the original dbCombo and change their selection, hence using the Change event.
Hope that makes it a bit clearer.

Johannes Schade
Sep 18th, 2000, 12:48 AM
In that situation I use the following:
Data1.Recordset.Move dbCombo.SelectedItem - 1, 1
strSQL = "SELECT ... : _
& "WHERE ...=" & Data1.Recordset!ID
Data2.Recordsource = strSQL
Data2.Refresh
It is not elegant at all and I suppose there should be better, but at least it works. Please criticise me freely and thanks for your elaboration.