If statement

  • Thread starter Catcher via AccessMonster.com
  • Start date
C

Catcher via AccessMonster.com

This is probably simple but I can't seem to get my syntax right.

The field order by has two "types" of data. Most have a five digit qualifier
on the end that is lopped off using:

OrderBYAbbreviated: Left([data.OrderBy],Len([data.OrderBy])-5)

This works as intended. The other "type" is a single value; "wuser". I need
a statement that says if value = wuser, then "wuser", else lop off the last 5
digits as above. Thanks.
 
M

Marshall Barton

Catcher said:
This is probably simple but I can't seem to get my syntax right.

The field order by has two "types" of data. Most have a five digit qualifier
on the end that is lopped off using:

OrderBYAbbreviated: Left([data.OrderBy],Len([data.OrderBy])-5)

This works as intended. The other "type" is a single value; "wuser". I need
a statement that says if value = wuser, then "wuser", else lop off the last 5
digits as above. Thanks.

If it's always "wuser", then you can use:

OrderBYAbbreviated:
IIf([data.OrderBy]="wuser","wuser",Left([data.OrderBy],Len([data.OrderBy])-5))

Do you really have a field name with a dot in it? If not,
then the [ ] are wrong.
 
C

Catcher via AccessMonster.com

That did it thanks. The dot is from tablename.fieldname.

Marshall said:
This is probably simple but I can't seem to get my syntax right.
[quoted text clipped - 6 lines]
a statement that says if value = wuser, then "wuser", else lop off the last 5
digits as above. Thanks.

If it's always "wuser", then you can use:

OrderBYAbbreviated:
IIf([data.OrderBy]="wuser","wuser",Left([data.OrderBy],Len([data.OrderBy])-5))

Do you really have a field name with a dot in it? If not,
then the [ ] are wrong.
 
M

Marshall Barton

If "data" is the name of the table, then [data.OrderBy] is
wrong and the query should fail. Actually that table and
field name do not need any [ ], but if you feel better using
them, it would have to be [data].[OrderBy]
--
Marsh
MVP [MS Access]

The dot is from tablename.fieldname.

Marshall said:
Do you really have a field name with a dot in it? If not,
then the [ ] are wrong.
 

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