Combo box data type problem

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

Hi,

On my form I have a number of combo boxes. I need to change what data these
are populated with dynamicallay.

To do this, I set the rowsource to "", update the .sql of the underlying
query, then reset the rowsource to the query.

I am using the same query for all of the combos (there are a lot of them).

Most of the time this works fine, but sometimes, when changing sql of the
underlying query from one that returns dates (or numbers) to one that
returns strings, I get error messages about invalid data types "The value
you entered isn't valid for this field".

It seems that sometimes the combo 'remembers' that it was previously bound
to a query that returned numeric data, and when you change it to string,
although the values have populated, you can't choose them because the combo
is still expeting numerics.

I can't find a property that determines what sort of data the combo is
expecting. It appear to be something that Access figures out for itself.

How can I reset the combo so that I no longer get this error?

TIA

Paul
 
I'm pretty sure that no such property exists.
What I find to be more likely is that when you change the
query (because it is the same query for all comboboxes) at
one point in time one of the _tables_ underlying the form
expects a date but receives a string from the query. You
might want to check which combobox exactly is giving you
the problem, what the value is you are trying to enter when
the error occurs, and what field the combobox is bound to.

It's a vague guess, but I hope this helps

Chris
 
...You
might want to check which combobox exactly is giving you
the problem, what the value is you are trying to enter when
the error occurs, and what field the combobox is bound to.

It is all the combos, if you set a text list in one, then set the next two
to (say) a date list, then return to the first and reselect a text list, the
combo 'expects' a numeric/date and will not accept a string. All the combos
are unbound.


I have done a lot more experimenting now...

It appears that the first time a drop down is populated, that is when Access
determines what the underlying data type is. You cannot then reset this
property.

A solution that appears to work is to populate the combos with a query that
returns a string and fire the dropdown property of each in turn when the
form loads.

If you do this, the combo continues to expect string input even after you
clear the rowsource and replace it with a rowsource that consists of numeric
data.

It's a pain that Access doesn't figure out what the data type is each time
the rowsource is changed or allow you to set it through a property. I am
using Access 2k btw. I may try to see what happens in xp and 03 to see if
this little quirk is fixed.
 
Back
Top