Solved

DataCombo (DBCombo) Returning Wrong Value

Posted on 2000-02-13
6
359 Views
Last Modified: 2008-03-03
The problem is actually in the DBLIST32.OCX file that ships with VB 6, and by using an old version of DBLIST32.OCX from VB 5, the problem goes away.

If you set up one text box bound to one data control, and the DBCombo bound to anoter Data Control, with the below settings, and put two msgBox lines, displaying which record value you have selected, in the Change event, the msgBoxes will have two different values.  See the steps below.  The same code in the Click event, seems to work.  If the Change does work, then if you move the code to the Click, it works, but if you move it back to the Change, it stops working.  Also, I am not getting the textbox, via the other data control, to show the name selected.  Any ideas?

Side Effect:
Unfortunately, if a VB5 application is installed on a machine, then someone else installs an application written with VB 6 that includes DBLIST32.OCX, it will update the file, thereby "breaking" the application!

Sample Steps and Code:
Below is a "simplified" set of steps to create the problem from a blank project using the Microsoft "standard" MDB file "biblio".

1. Create a new project
2. From Project, Components, add Microsoft Data Bound List Controls 6.0
3. Place a data control on the form.
     Name: dataTitles
     Databasename: Biblio
     RecordSource: Titles
4. Place a data control on the form.
     Name: dataPub
     Databasename: Biblio
     RecordSource: Publishers
5. Place a textbox on the form.
     DataSource: dataTitles
     DataField: Title
6. Place a DBCombo on the form.
     RowSource: dataPub
     ListField: Name
     BoundColumn: PubID
     DataSource: dataTitles
     DataField: PubID
7. Add this code to the Change event for DBCombo1
      MsgBox DBCombo1.Text & " " & DBCombo1.BoundText
      MsgBox DBCombo1.Text & " " & DBCombo1.BoundText
8. Run the program. Choose a different publisher from the dropdown.
9. Two message boxes will be displayed with different results in each. There is no reason why the values should change between the two MsgBox statements!
10. Move the code from the Change to the Click event for DBCombo1.
11. Run the program, and choose a different publisher from the dropdown.
12. Both MsgBox statements show the same value this time!
0
Comment
Question by:MMILLER
  • 3
  • 2
6 Comments
 
LVL 32

Expert Comment

by:Erick37
ID: 2517199
See:
"FIX: Change Event Not Fired When Selecting an Item in DBCombo"

http://support.microsoft.com/support/kb/articles/Q172/2/48.asp
0
 

Author Comment

by:MMILLER
ID: 2517459
Does that go for VB6?  The article is about VB5.

0
 
LVL 32

Accepted Solution

by:
Erick37 earned 70 total points
ID: 2517494
The previous article refers to VB5, prior to the service pack updates.

MS has an example of using 2 data controls and a dbcombo:

"HOWTO: Synchronize Data on the Form with a dbCombo"

http://support.microsoft.com/support/kb/articles/Q143/4/21.asp
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:MMILLER
ID: 2518507
One last comment.  The problem exists in VB6 using Data and DBCombo.  I have SP3, plus that data update they put out.

Is MS aware of the VB6 problem using those controls and have they fixed that yet?

And thanks for the sample.  I'll try that.
0
 
LVL 5

Expert Comment

by:Bhaskar Ganapathe
ID: 2530404
Hello MMiler,

I am getting the same answer with the
two msgboxes in the change event of
the dbcombo1.

I did the same way as you are given.
just try it and reply
0
 

Author Comment

by:MMILLER
ID: 2531258
>>I am getting the same answer with the
two msgboxes in the change event of
the dbcombo1.

I did the same way as you are given.
just try it and reply

<<

Bhaspup,
Do you mean with Erick37's sample of "how to", which refers to VB5?

If you are saying that you get the correct answer with VB6 using my steps above, then I did get the correct answer, with the steps above, on my FIRST pass.  Then I changed it to Click, then back again, and it stopped working.  My steps above, definitely produce unstable results.  I still have to try the "how to" sample from Erick under my VB6, though.  I am going to accept and close out Erick's comment.  If it doesn't work, I will have to come back.

Michael
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now