mascot
10-27-2011, 03:56 PM
I am working on a form that has checkboxes with grocery list items for the captions. I would like to be able to create a grocery list from each item I check on the form using these captions and then put this on a word document through a bookmark. I am a newbie. I'm trying to search around to find information. I've been able to piece some stuff together but I keep getting compiling errors. Here is the code I have for iterating through each checkbox control to see if it is checked and if it is True then add it to an array. It doesn't work so I was hoping someone with some experience could help. Maybe I'm going about this all wrong. I'm not sure. Thanks
Dim x as Integer
Dim ctrl as Control
Dim myArray() as String
x=1
For Each ctrl In Me.Controls
If TypeName(ctrl) = "TextBox" and Value = True Then
x=x+1
ReDim Preserve myArray (1 to x)
myArray = Me.Ctrl.Caption
End If
Next
Dim x as Integer
Dim ctrl as Control
Dim myArray() as String
x=1
For Each ctrl In Me.Controls
If TypeName(ctrl) = "TextBox" and Value = True Then
x=x+1
ReDim Preserve myArray (1 to x)
myArray = Me.Ctrl.Caption
End If
Next