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

Convert Number to text in Access query

Status
Not open for further replies.

nyamrembo

Technical User
Apr 15, 2010
52
US
Hi,
I have a lookup field that I am trying to query but I am getting "Data type mismatch in expression criteria". The lookup field type is number but field type from original table is text. I tried to change the lookup field to text but when I did that, my query is not yielding results. Is there a way to convert a number field to text? I have checked the web and the forum but I only found text to number.

Thank you much
[sunshine]
 


Hi,

It depends how the TEXT numeric characters are structured.

Some examples of the Character 1
[tt]
1
1
00001
[/tt]
Each are a DIFFERENT VALUE.

So how are your text numeric characters structured?


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
The field size is long integer...how it's stored, I am not sure, could be 4-8 bytes.
[ponder]
 
A long integer is 8 bytes long.

You can compare text and numeric fields in SQL by doing an on-the-fly conversion of text to numeric assuming that the text field contains only characters that can be converted to numeric values. For example
Code:
WHERE Val(SomeTextField) = SomeNumericField

Converting in the other direction (i.e. numeric to text) has the problems that Skip is referring to. For example
Code:
Where '0001' = '   1'
returns FALSE even though
Code:
Where Val('0001') = Val('   1')
is TRUE.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top