Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

After Changing order of a Table, wron item is selected in combobox.

Status
Not open for further replies.

qwertzuiopasdfghjkl

Programmer
Feb 17, 2006
5
DE
Hy folks,

hope you can help me with my problem.

I have a comboboxes in a Class-container bound to a table. Im setting the order to "Order2" and do a seek(). After finding or not I change the Order back to its origin ("Order1").

the Problem lies within the drop-down-list of the combobox. It wont show the correct Entry as selected. For example we found entry 4 during the seek() with name "General Motors". After changing the Order back entry 4 is selected in the combobox with name "CarCompany2". But thats not the entry that should be selected it should be "General Motors". Now how can i tell the combobox to select by name and not by index. Or tell it to just select the right entry.

Following are the presets of the combobox. If you need anymore I am happy to provide them.
ColumCount = 1
RowSource = TabMarke.Marke
RowSourceType = 2 (Alias)

All of these are set during the init of the container.

Hope i the problem is clear and any one of you has any ideas to solve this.
 
the Problem lies within the drop-down-list of the combobox. It wont show the correct Entry as selected. For example we found entry 4 during the seek() with name "General Motors". After changing the Order back entry 4 is selected in the combobox with name "CarCompany2". But thats not the entry that should be selected it should be "General Motors". Now how can i tell the combobox to select by name and not by index. Or tell it to just select the right entry.

Off the top of my head and untested:

Code:
IF SEEK( << Some Value >>, [TabMarke], [Order2] )
  This.Value = TabMarke.SomeField
ELSE
  This.ListIndex = 0
ENDIF



Marcia G. Akins
 
Beside the else branch, my code looks alike.
After further investigation i found another weird thing.
I'm working with two cases here.

First case:

Order of table gets changed. Wrong entry selected but at least selected.

Second case:
no order change. No entry selected.

in both cases an entry is found.

the seek comman is the same in both cases:

IF FOUND() THEN

this.cboMarke.Value = TabModell.Modell
this.cboMarke.Requery
this.cboMarke.Refresh

ELSE
MESSAGEBOX("Error")
ENDIF

Is there a way to have a combobox remember the selection on a string basis? Or any way we can track the selection by name.
 
this.cboMarke.Value = TabModell.Modell
this.cboMarke.Requery
this.cboMarke.Refresh

You do not want the Requery() and the refresh().
You only need to requery() the combo when the data in underlying RowSource (in this case the alias) has changed. And you do not want a refresh here either. If this is abound control, a refresh updates the value from its ControlSource and you just set the value here.

What method is your code in?




Marcia G. Akins
 
All right, trying to explain on what im working.

I have a table with car manufactors and modells.
I open the table once with a unique order for all the manufactors (TabMarke) . The same table is opened again with order on the models (TabModell).

For each Table i have a combobox in class container. If you choose a manufactor in TabMarke the combobox with TabModell is enabled and you can only choose Modells from that manufactor.

In the INIT of the container I change the order to an unique index called KFZ-ID. And do a seek in both tables.
If the manufactor was found the combobox gets its value. the same goes with the modell.

So far. everything works fine. The value of the comboboxes are the way they should be, but..
When you open the dropdown box of the combobox the selected items is not the same as the value.


To trace this ... thing. Make a combobox, build a cursor with three items and two orders. Select one item in the combobox and change the order. Magicly when you reopen the combobox the wrong item is selected.

Hope all this clearifies things. Thank you all for your help so far. Maybe its just a simple thing but i can't get around.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top