General discussion

Locked

Visual Basic 6 application development

By fakhruddin_c ·
I'am developing a VB application.I'am populating a standard combo box with the data from the database.I want that when I change or select a value at run time from the combo box it should select the other fields from the same table for the value selected from the combo box.The change event for the combo box doesn't get fired when i try to change it's value at run time.
Please give me some tips so as to work out the problem.

My next question is based on the above question.Now i'am having a nother combo box on the same form.Depending on the value selected in the first combo box I want the second combo box to be populated with some related data from a different table.The first and second table are having proper relationships.
When I'am writing a change event for the first combo box it doesn't get fired though there are coresponding records present in the second table which populates the second combo box on the form.
Do reply me early

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Visual Basic 6 application development

by sl-campbell In reply to Visual Basic 6 applicatio ...

Question #1:
The Change event doesn't occur when the style property is set to 2
Use the Click event when the style property is set to 2.

Question #2:
There are serveral ways of going about this:

1-Using only bound controls
2-Using partially bound controls and the rest by building recordset objects
3-Get all data using recordset objects.

Using Bound controls:
Use 2 data controls, each with a different record source - the first one gets all data and fields desired from the first table and the second one gets all data from the second table.
The first combo box is bound to the data1 control. The second one is also bound to the data1 control with the data field set to the key field used in both recordsets. The row source of the second combo is set to the data2 control. The bound column is set to the key Field from data2. The ListField is the field that you want to see in combo2.

Using Non Bound Controls:
I prefer and would do it :
I would create a recordset object including all desired fields to returned by Combo1 including the field that needs to show up in combo1.
Then do a loop through the rs, getting the values of the field to show in combo1 and adding then to the combo1 box.
When the user selects an item, get the field value from combo1 and then using this value do a FindFirst on the recordset. Then you can return all field values and update the form.

For the second set of data:
Just take the value from the combo box, (or another field after doing the FindFirst), and use this as criteria when building a second recordset to get all the related data from another table and fill the second combo box.

Collapse -

Visual Basic 6 application development

by sl-campbell In reply to Visual Basic 6 applicatio ...

Did this answer your question?

Collapse -

Visual Basic 6 application development

by sl-campbell In reply to Visual Basic 6 applicatio ...

Can you close this?

Collapse -

Visual Basic 6 application development

by fakhruddin_c In reply to Visual Basic 6 applicatio ...

The question was auto-closed by TechRepublic

Collapse -

Visual Basic 6 application development

by sl-campbell In reply to Visual Basic 6 applicatio ...

Can you close this?

Collapse -

Visual Basic 6 application development

by fakhruddin_c In reply to Visual Basic 6 applicatio ...

The question was auto-closed by TechRepublic

Collapse -

Visual Basic 6 application development

by fakhruddin_c In reply to Visual Basic 6 applicatio ...

This question was auto closed due to inactivity

Back to Web Development Forum
7 total posts (Page 1 of 1)  

Related Discussions

Related Forums