jwcolby
jwcolby at colbyconsulting.com
Wed Dec 5 10:41:30 CST 2007
As you saw from the air code, feeding the values into a paramarray "gets them into an array" and you are done. If that is all you are after you could literally just have a function with a ParamArray for the input and passes back that same array as the function exits. John W. Colby Colby Consulting www.ColbyConsulting.com -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Hale, Jim Sent: Wednesday, December 05, 2007 10:07 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Loading checkbox values into an array Thanks John, I think this points me in the right direction. I became intrigued by Kostas requirement last week to compute workdays between dates. I developed a form and code to do this but now I am refining the code. Currently I have a form with all the US holidays listed. The user checks which ones he wants included as holidays in the calculation. The code determines which day holidays fall on then I have code like this: Function Holiday(datDateIn As Date) As Boolean 'Determine if date is a holiday (ie non workday) 'the dates for New years, memorial day, etc for the selected year were set in a different function Holiday = False Select Case datDateIn Case NewYears If Forms!frmWorkdays_Between_Dates.chkNewYears = True Then Holiday = True Case Memorial_Day If Forms!frmWorkdays_Between_Dates.chkMemorial = True Then Holiday = True Case July4th If Forms!frmWorkdays_Between_Dates.chkJuly4th = True Then Holiday = True Against which I test every date in a selected range to determine if it is a holiday and if the user wants it included in the calculation. This seems very clunky and so I figured an array could tighten the code. Actually, I think I can get this whole program into a class using With Events but it needs some more work first. The array I need should have true/false (ie true if the user wants the holiday included) and the name of the holiday (I may include this in the tag property of the control). I can use the array to replace the if stmts in the code above. Thanks, Jim Hale -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby Sent: Tuesday, December 04, 2007 6:39 PM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] Loading checkbox values into an array Give us a little more info. Why do you need to load into an array? An array of what? (air code) function LoadArray (ParamArray varCtls() as variant) dim ctl as control dim Arr(13) as variant dim intIndex as integer for each ctl in varCtls arr(intIndex) = ctl.value intindex+=1 next ctl LoadArray = Arr end function ?LoadArray(Chk1, Chk2, Chk3 etc etc)(0) returns an array and displays the 0th element Something like that? You really should do some error checking to see how many objects varCtls contains in case you pass in 14 controls (you'd get a runtime error). John W. Colby Colby Consulting www.ColbyConsulting.com -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Hale, Jim Sent: Tuesday, December 04, 2007 6:25 PM To: accessd at databaseadvisors.com Subject: [AccessD] Loading checkbox values into an array OK, this should be easy burt I guess its late and I can't recall how to do it. I have 13 checkboxes on a form. I need to load their values (true, false) into an array. Anyone want to jog my memory? TIA Jim Hale *********************************************************************** The information transmitted is intended solely for the individual or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of or taking action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you have received this email in error please contact the sender and delete the material from any computer. As a recipient of this email, you are responsible for screening its contents and the contents of any attachments for the presence of viruses. No liability is accepted for any damages caused by any virus transmitted by this email. -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com *********************************************************************** The information transmitted is intended solely for the individual or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of or taking action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you have received this email in error please contact the sender and delete the material from any computer. As a recipient of this email, you are responsible for screening its contents and the contents of any attachments for the presence of viruses. No liability is accepted for any damages caused by any virus transmitted by this email. -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com