×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Len, Val(Mid)

Len, Val(Mid)

Len, Val(Mid)

(OP)
thread702-1705763: Recurring Data and Yearly Calender Summary

Hi

the above thread was closed and I think Duane mentioned that there would be a problem when some dates that have 1 or 2 characters at the start.



On the attached image i'm having problems showing the correct values as some dates have 1 character and some have 2 at the very beginning of the string, the problem only happens on the 2nd week of each month, I've worked out the other days using:

CODE

=IIf(Len([11])=11,Val(Mid([11],4,2)),IIf(Len([11])=12,Val(Mid([11],4,2)),IIf(Len([11])=13,Val(Mid([11],5,2)),Val(Mid([11],3,2))))) 

It also only happens when the string count is 12 in the 2nd week, the count of children on each day (in blue) is calculated using:

CODE

Val: Max(Day([TheDate])) & Chr(13) & Chr(10) & Abs(Sum([strSessionDayCount]="X")) & Chr(13) & Chr(10) & Max([strSessionGrp]) & Chr(13) & Chr(10) & Min([IsHoliday]) 

on the 8 April, based off the above, the values are:

8 chr13 Chr 10 (3)
25 chr13 chr 10 (4)
X chr13 chr 10 (3)
-1 (2) the minus 1 is because this day is a school holiday

this shows the number of children "25" correctly using Val(Mid([11],4,2)

but for the 10 June, the values in the field are:

10 chr 13 chr10 (4)
27 chr 13 chr10 (4)
X chr 13 chr10 (3)
0 (1)

this shows the number of children "7" incorrectly, the Val that I should be using Val(Mid([11],5,2)

I'm not sure how I change the code so that if the string count = 12 but the date is only 1 character to use: Val(Mid([11],4,2) or when
the string count = 12 and the date has 2 characters to use Val(Mid([11],5,2)

I thought about using the LEFT and LEN together so the new statement would have 5 conditions but i'm not sure if you can combine them in that way:

IIf(Len([11])=11,Val(Mid([11],4,2))
IIF(LEFT([11)=1 and LEN([11)=12,Val(Mid([11],4,2))
IIF(LEFT([11)=2 and LEN([11)=12,Val(Mid([11],5,2))
IIf(Len([11])=13,Val(Mid([11],5,2))
Val(Mid([11],3,2)

Thanks

Mikie












RE: Len, Val(Mid)

I'm not sure of all the logic and conditions but I am sure that I would create a small user-defined function that would accept the needed values and return exactly what is needed. Combining multiple expressions/calculations can more easily be managed in code where you can add comments, use If/End If, use Select Case, and re-use again and again while maintaining in one module.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close