Link to home
Start Free TrialLog in
Avatar of Conernesto
ConernestoFlag for United States of America

asked on

Access query expression

I have a table with a field called "ST". In the field ST there are records with two digits or more. I need an expression that will get records that  only have two digits. I also need an expression that will give the record if the record has  more than two digits. See sample  below of what I have and what I want. Can you provide an expression that will do this? Thank you.

Have                                                     Want Expression1         Want Expression2

NY                                                                   NY
OHCOL                                                                                                    OHCOL
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Conernesto

ASKER

In the same query, I want one expression to have the items with only two digits and in the second expression I want the items the have more than two digits.
Then try my first suggestion.  I asked the question only because the request didn't make sense to me.
Are you able to send me the above in non SQL format?
Not if you want it in a query.  Just create a new query and switch to SQL view.  copy and paste my query and then change the column and table names to match your database.

If you want the expression to be the ControlSource for an unbound control, then ithey would look like:

ControlA ControlSource
=IIf(Len([ST]) = 2, [ST], Null)

ControlB ControlSource
=IIf(Len([ST] <> 2, [ST], Null)

The ControlSource property is on the Data tab of the control's properties dialog.  Put the expression including the leading "=" into the property named ControlSource.
Thank you.