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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ControlSource recordsource grief 1

Status
Not open for further replies.

derren

Programmer
Mar 22, 2001
500
GB
This is something which I have "avoided" [using homemade means] along time ago because it has wound me up, but it has come up again, and it needs sorting [evil]

I have a table field which contains a numeric value which relates to a lookup table containing a related image and text description.

I have a dropdown combo, which gets its rowsource from the aforementioned lookup table:
3 columns - 1 for the visible label, 2 as the boundcolumn field and 3 as the image name

The controlsource of the combo is set to the field from the first table and I am hoping that by setting the boundcolumn to "2", the value of column two of the combo will control the field value. This has worked successfully in other saituations but this may be fluke.

When the dropdown is used I would like the text in the combobox to reflect the new choice, automatically change the value of the controlsource table field and change the image to the new value.

The image is changing (easy) but when I change the value of the combo it changes to the new value but then immediately reverts back to its original value (d'oh!). I am getting so far up my own **** now that I cannot see the best way to sort this. I am convinced that I have the whole concept of what to do with control sources wrong and that I need some guidance. Any ideas?


Derren
[Mediocre talent - spread really thin]
 
A combobox's ControlSource property ALWAYS returns a Character value. Try setting your table relationship in code to something like VAL(cmbFieldName)

Ian
 
Aha! That might be upsetting it. It doesn't error though, wouldn't it scream if I tried to do this or does it just disregard what I have asked? Derren
[Mediocre talent - spread really thin]
 
Heh...you would THINK so. However, a combobox DOES allow you to set its value to a numeric type. It simply converts it to character for you.

If you look back through posts made by me, you'll find that I asked this same question some time ago. I learned the hard way. LOL

Ian
 
Cheers Ian - I shall search away! Derren
[Mediocre talent - spread really thin]
 
Well, although I am almost back to my original workaround (what're the chances of that?) at least I know now why it only worked (and darn well) some of the time.

It's those intermittent faults which really wind you up!

There is no relationship set between the two tables, but it just seemed to dislike the setting of the controlsource numeric field to a character value.

Ironically, when I set the value of the "parent" field using this.value it sends a numeric value and doesn't need the usual int(val()) shennanigans. If only the controlsource property could do this!

Derren
[Mediocre talent - spread really thin]
 
Derren,

If you're using the VALUE property and getting a numeric value, you're probably getting the row number, not the actual value from column 2. Beware!

Ian
 
Aha! That is why! I thought that by using the boundcolumn property and setting it to the column that I want to be the value that it would give to the controlsource. I am getting boundcolumn, boundto and controlsource all messed up then.

Can I use "this.list(this.listindex,2)" as the controlsource for my field? And is that the best way to get the currently selected value of column 2 of a combo? Derren
[Mediocre talent - spread really thin]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top