Combo result is text when should be numeric

L

Lester Lane

Hi, I've never had this before but I notice when stepping through my
code that a combo that returns the AutoNumber ID field (numeric in the
table) is holding it as a string. Why? How has this happened? I
have not converted it in the query that is the record source. Using
Access 2003. Thanks in advance.
 
K

Klatuu

All values in controls are held as text representations.
What problem is this causing you?
 
A

Allen Browne

If the combo is bound to a numeric field (including AutoNumber), its Value
will be numeric.

If the combo is unbound, but the Bound column is the AutoNumber, set its
Format property to something numeric (e.g. General Number), and Access will
treat is as numeric.

If the AutoNumber is not the bound column of the combo, the value is treated
as text. You can typecast it, e.g.:
Val(Nz([Combo1], 0))
 
L

Lester Lane

If the combo is bound to a numeric field (including AutoNumber), its Value
will be numeric.

If the combo is unbound, but the Bound column is the AutoNumber, set its
Format property to something numeric (e.g. General Number), and Access will
treat is as numeric.

If the AutoNumber is not the bound column of the combo, the value is treated
as text. You can typecast it, e.g.:
    Val(Nz([Combo1], 0))

--
Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


Hi, I've never had this before but I notice when stepping through my
code that a combo that returns the AutoNumber ID field (numeric in the
table) is holding it as a string.  Why?  How has this happened?  I
have not converted it in the query that is the record source.  Using
Access 2003.  Thanks in advance.

That explains it! Thanks, mine were unbound. A simple format to
Standard 0 dec places and left justify to get what I want - a numeric
value. The problem was in code when trying to see if two fields were
equal. But it works now! PS This never was the case in Access 2000.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top