G
Guest
Is it possible to query a text field in a table?
I'd like to determine if Column A is < Column B.
Thanks.
I'd like to determine if Column A is < Column B.
Thanks.
Is it possible to query a text field in a table?
I'd like to determine if Column A is < Column B.
Thanks.
John Vinson said:Is it possible to query a text field in a table?
I'd like to determine if Column A is < Column B.
Thanks.
Sure. Put a criterion on Column A of
< [Column B]
Note that for a text field the comparison is *alphabetical* - that is,
"Aardvark" will sort before "Zebra", but "10224" will sort before "2".
If the text field contains numeric values and you want the comparison
to be done numerically rather than alphabetically, use instead
Val([Column A]) < Val([Column B])
John W. Vinson[MVP]
I am having trouble getting the Val correct. I've tried putting it in the
sql:
SELECT [QAR's_2005].ID, [QAR's_2005].[QAR Associated #],
[QAR's_2005].[Analysts name], [QAR's_2005].[Date turned in],
[QAR's_2005].[QAR number], [QAR's_2005].[QAR start date], [QAR's_2005].[QAR
end date], [QAR's_2005].[Timeliness/Accuracy], [QAR's_2005].[Error Rate],
[QAR's_2005].[AQL Requirement], [QAR's_2005].[Date of COTR Sig],
[QAR's_2005].[Date Issued], [QAR's_2005].[Return Date],
[QAR's_2005].[Rebuttal Yes/No]
FROM [QAR's_2005]
WHERE Val([Error Rate]) < Val([AQL Requirement]);
and get "Data type mismatch in criteria experssion"
John Vinson said:I am having trouble getting the Val correct. I've tried putting it in the
sql:
SELECT [QAR's_2005].ID, [QAR's_2005].[QAR Associated #],
[QAR's_2005].[Analysts name], [QAR's_2005].[Date turned in],
[QAR's_2005].[QAR number], [QAR's_2005].[QAR start date], [QAR's_2005].[QAR
end date], [QAR's_2005].[Timeliness/Accuracy], [QAR's_2005].[Error Rate],
[QAR's_2005].[AQL Requirement], [QAR's_2005].[Date of COTR Sig],
[QAR's_2005].[Date Issued], [QAR's_2005].[Return Date],
[QAR's_2005].[Rebuttal Yes/No]
FROM [QAR's_2005]
WHERE Val([Error Rate]) < Val([AQL Requirement]);
and get "Data type mismatch in criteria experssion"
Hrm. The criterion looks unexceptional. My biggest concern would be
the use of ' and / in table and field names - since ' is a string
delimiter this can get pretty wierd. Could you try renaming the table
to get rid of the apostrophe?
What are the *actual contents* of the Error Rate and AQL Requirement
fields? Are there leading % signs or other nonnumeric characters, or
leading blanks?
John W. Vinson[MVP]
I renamed the table and removed the '
The *actual contents* include
99.5%
95%
100%
99.75%
etc. This is all I see in the fields. Doesn't appear to be any leading %
signs or blanks.
KMT said:Removed all % in the table. The 'replace' function not working for Access
2000.
KMT said:I appreciate the reply, but the real problem I'm having is determining which
of two text fields (with numbers such as 99.5, 100, etc) is greater than the
other.
Run the sql, Val([Error Rate]) < Val ([AQL Requirement]);
still get error
On Query Grid: When I put in the criteria line of the Error Rate Column
<AQL Requirement
It returns all in the table, even those less than comparison field in AQL
Requirement column.
When I change it to > AQL Requirement (still in criteria line of Error Rate
column)
It returns nothing, although the majority of the records actually have Error
Rate greater than AQL Requirement.
Ideas?
KT
Douglas J. Steele said:Actually, the replace function does work in Access 2000, but if you haven't
applied all of the service packs, you have to do a work-around which
involves creating a "wrapper" function that you call in your query:
Function MyReplace(Expression As String, _
Find As String, _
Replace As String) As String
MyReplace = Replace(Expression, Find, Replace)
End Function
Rather than using Replace(x, y, z) in your query, use MyReplace(x, y, z)