Functions don't work in 2007

K

KMK

I have been unsuccessful in getting functions, such as trim, to work in
Access 2007. When I have a query and enter rtrim("A") and then run a
datasheet, it comes up blank. If I delete the trim function, the query works
fine.

I am also having problems with IIf functions on reports. =IIf([Cost]
="<10000","Good","Bad"). The result is Bad no matter what the cost is.
 
R

RonaldoOneNil

Don't know about the Trim but the iif doesn't work because you have quotes
around your check. You are saying if [cost] equals the string "<10000" ...
It should be like this
=IIf([Cost]<10000,"Good","Bad")
 
K

KMK via AccessMonster.com

Thanks so much for the help. The IIf finally works. However, I still can
not get the trim to work.
Don't know about the Trim but the iif doesn't work because you have quotes
around your check. You are saying if [cost] equals the string "<10000" ...
It should be like this
=IIf([Cost]<10000,"Good","Bad")
I have been unsuccessful in getting functions, such as trim, to work in
Access 2007. When I have a query and enter rtrim("A") and then run a
[quoted text clipped - 3 lines]
I am also having problems with IIf functions on reports. =IIf([Cost]
="<10000","Good","Bad"). The result is Bad no matter what the cost is.
 
K

KARL DEWEY

You formula -- rtrim("A") can not do anything as RTrim is meant to remove
added spaces from the right side of a string. "A" does not have spaces.

Now if you have a field named 'A' then do it this way --
RTRim([A])

KMK via AccessMonster.com said:
Thanks so much for the help. The IIf finally works. However, I still can
not get the trim to work.
Don't know about the Trim but the iif doesn't work because you have quotes
around your check. You are saying if [cost] equals the string "<10000" ...
It should be like this
=IIf([Cost]<10000,"Good","Bad")
I have been unsuccessful in getting functions, such as trim, to work in
Access 2007. When I have a query and enter rtrim("A") and then run a
[quoted text clipped - 3 lines]
I am also having problems with IIf functions on reports. =IIf([Cost]
="<10000","Good","Bad"). The result is Bad no matter what the cost is.
 
K

KMK via AccessMonster.com

I've got a field that could contain 1, or 01, or 01A, or 01B, or 1C and I'm
trying to get read of the A, B, and C. Output would be 1 or 01. Maybe trim
is not the way to do it?


KARL said:
You formula -- rtrim("A") can not do anything as RTrim is meant to remove
added spaces from the right side of a string. "A" does not have spaces.

Now if you have a field named 'A' then do it this way --
RTRim([A])
Thanks so much for the help. The IIf finally works. However, I still can
not get the trim to work.
[quoted text clipped - 9 lines]
I am also having problems with IIf functions on reports. =IIf([Cost]
="<10000","Good","Bad"). The result is Bad no matter what the cost is.
 
K

KMK via AccessMonster.com

I've got a field that could contain 1, or 01, or 01A, or 01B, or 1C and I'm
trying to get read of the A, B, and C. Output would be 1 or 01. Maybe trim
is not the way to do it?


KARL said:
You formula -- rtrim("A") can not do anything as RTrim is meant to remove
added spaces from the right side of a string. "A" does not have spaces.

Now if you have a field named 'A' then do it this way --
RTRim([A])
Thanks so much for the help. The IIf finally works. However, I still can
not get the trim to work.
[quoted text clipped - 9 lines]
I am also having problems with IIf functions on reports. =IIf([Cost]
="<10000","Good","Bad"). The result is Bad no matter what the cost is.
 
K

KMK via AccessMonster.com

I've got a field that could contain 1, or 01, or 01A, or 01B, or 1C and I'm
trying to get read of the A, B, and C. Output would be 1 or 01. Maybe trim
is not the way to do it?


KARL said:
You formula -- rtrim("A") can not do anything as RTrim is meant to remove
added spaces from the right side of a string. "A" does not have spaces.

Now if you have a field named 'A' then do it this way --
RTRim([A])
Thanks so much for the help. The IIf finally works. However, I still can
not get the trim to work.
[quoted text clipped - 9 lines]
I am also having problems with IIf functions on reports. =IIf([Cost]
="<10000","Good","Bad"). The result is Bad no matter what the cost is.
 
P

Philip Herlihy

KMK said:
I've got a field that could contain 1, or 01, or 01A, or 01B, or 1C and I'm
trying to get read of the A, B, and C. Output would be 1 or 01. Maybe trim
is not the way to do it?
....
You mean "get rid", right?

The most generalisable way of handling data like this is "Regular
Expressions" - a facility which allows you to express the general
structure of a data item and access its components. Astonishingly
powerful once you get the hang of it. I've never had occasion to use
them in Access (although I regularly use them in other tools) so I
looked for a suitable web reference for you. The best seems to be this one:

http://www.accessmvp.com/DJSteele/SmartAccess.html
(see the second item).

The time invested in learning regular expressions WILL be repaid.
However, Regular Expressions are for those used to (or prepared to
learn) some quite intricate coding.

Instead, you might play around with the functions LEFT, RIGHT, MID, LEN,
INSTR and ISNUMERIC. Alternatively, you could set up a SELECT CASE
block to match specific values. You'll see it's quite easy to lift
specific characters from a specific string - the tricky bit is to do the
right thing when presented with a variety of different combinations, and
you'll need a clear understanding of what might appear in that field
before you can write the appropriate code. Once you've worked out how
to extract the numeric part reliably from whatever data might appear in
your tables, you may want to wrap the code in a function in a VBA module
and call that in your query, so you can refer to
=JustNumeric([stringfield]). Be sure to include error handling code:
see: http://allenbrowne.com/ser-23a.html

One thought - these couldn't be Hex numbers, could they?

Phil, London
 
A

AccessVandal via AccessMonster.com

Try...

Left("String", Len("String")-1)

Left("01A"), Len("01A") -1) should give you "01". Try it in your immediate
window....like with the "?" in front and press enter.

?Left("01A"), Len("01A") -1)

It might throw an error in VBA, if that happens, use error trapping. Or
simply use Nz() or other builtin function to handle a null conditions.
I've got a field that could contain 1, or 01, or 01A, or 01B, or 1C and I'm
trying to get read of the A, B, and C. Output would be 1 or 01. Maybe trim
is not the way to do it?
You formula -- rtrim("A") can not do anything as RTrim is meant to remove
added spaces from the right side of a string. "A" does not have spaces.
[quoted text clipped - 7 lines]
I am also having problems with IIf functions on reports. =IIf([Cost]
="<10000","Good","Bad"). The result is Bad no matter what the cost is.
 

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