By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,808 Members | 1,481 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,808 IT Pros & Developers. It's quick & easy.

How to calculate the length of a fields value separated by comma & assign it to other

P: 8
in Access I have a table called Leaves in which Jan, Feb, Mar....Dec and Jantotal, Febtotal, Martotal.......Dectotal are fields

now lets say field Jan contains some data like " 01,07,21,29,31 " etc which is the total leave taken in month January here the total is 5 now I need to calculate this automatically after entering it in the form and assign this value to Jantotal

how is that possible I tried to convert it to an array and assigned the length of array to Jantotal but its not working properly the variable I used is not changing from record to next record

please provide me a solution
Aug 1 '08 #1
Share this Question
Share on Google+
3 Replies


puppydogbuddy
Expert 100+
P: 1,923
try this:
Expand|Select|Wrap|Line Numbers
  1. Dim intCount As Integer
  2.  
  3. ' - use split function, placing each line into array as an item
  4. JanTotal = Split("Jan",",")
  5. intCount = Ubound(JanTotal)
Aug 1 '08 #2

missinglinq
Expert 2.5K+
P: 3,532
Am I correct in that you simply want a count of the days entered, as you said, 5 for your example? If so a single line will also do it.

Expand|Select|Wrap|Line Numbers
  1. MonthTotal = Len([Month]) - Len(Replace([Month], ",", ""))+1
Welcome to Bytes!

Linq ;0)>
Aug 1 '08 #3

P: 8
Am I correct in that you simply want a count of the days entered, as you said, 5 for your example? If so a single line will also do it.

Expand|Select|Wrap|Line Numbers
  1. MonthTotal = Len([Month]) - Len(Replace([Month], ",", ""))+1
Welcome to Bytes!

Linq ;0)>
thanx its working fine
Aug 2 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.