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

IIF query problem

Status
Not open for further replies.

TTA23

MIS
Sep 26, 2006
41
US
I have a table with a numeric field named BIRTH. The data is similar to 11005 or 11100. This is 5 or 6 digits.
I want to create a field that will copy the first or 2 first digit from the birth field.
To do this I am using athe following formula in the 'Select query' form.

monthBirth: IIf(Len(Trim$([BIRTH])=5),Mid$(Trim$([BIRTH]),1,1),Mid$(Trim$([BIRTH]),1,2))

This will only retrieve the first digit from the field 'BIRTH'. I would like to retrieve the first digit if Lenght is 5 and the first 2 digits, if the length is 6.

Any help on this, as I am running out of ideas!!

Thanks in advance.
 
what about this ?
monthBirth: Left(BIRTH,Len(BIRTH)-4)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi,
Look good, but I get an 'Invalid procedure call' error message.
 
And this ?
monthBirth: Int([BIRTH]/10000)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
All work fine. This work as long as I am not using 'grouping' in the query.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top