Data from multiple check boxes going into one field

  • Thread starter Thread starter ADavis
  • Start date Start date
A

ADavis

Hi,

I know that each piece of data should have it's own field in most cases
but...

I basically have a question on a survey in which a person can choose
mulitple (5) options. So I want all the data to be stored in one
field.

I want the numeric data stored in a text field in this fashion: 2, 4, 5

Can someone help me with this? Option groups of course are not the
answer.

Cheers,
A Davis
 
Each piece of data should have its own field in *all* cases.

It is certainly possible to use code to copy the values of multiple controls
into one text field. An example follows. But I cannot stress strongly enough
that while it is possible to do this kind of thing, my advice is don't do
it. Take a look at Duane Hookom's 'At Your Survey' at the following URL
instead ...

http://www.rogersaccesslibrary.com/Otherdownload.asp?SampleName='At Your Survey 2000'

Here's the example. Remember, I do *not* recommend this.

Private Sub cmdTest_Click()

Dim lngLoop As Long
Dim strResult As String
Dim opt As OptionButton

For lngLoop = 1 To 5
Set opt = Me.Controls("Option" & CStr(lngLoop))
If opt.Value <> 0 Then
If strResult = vbNullString Then
strResult = CStr(lngLoop)
Else
strResult = strResult & "," & CStr(lngLoop)
End If
End If
Next lngLoop
Me.TestText = strResult

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top