Re: Help Again?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Ken Snell (kthsneisllis9_at_ncoomcastt.renaetl)
Date: 05/28/04


Date: Fri, 28 May 2004 10:24:48 -0400

One thing that jumps out at me is that you're setting the strlabelVal
variable to be the caption of the first option button/checkbox in the option
group, but you never reset it to the caption of the label for the second,
third, or fourth option button/checkbox? (If I am understanding that you
want this to change, that is.) So, in your last code block, you will always
see the same label caption -- namely, the first item's.

-- 
        Ken Snell
<MS ACCESS MVP>
"Pedro" <anonymous@discussions.microsoft.com> wrote in message
news:8FDA345D-78A0-4CCA-A84B-3F7F4C474897@microsoft.com...
> I have a form that is not bound to a table. it basically a check list. The
users need to choose one of 4 options for each item on the list. The option
group label contains the list item name. I need to retrieve this to enter it
into a table field along with the option they have chosen. There is a submit
button so that once they have entered the choices for each list item I am
then using a recordset to do the insert into the table. So I loop through
each option group extracting the label caption (list item) and the option
group value (choice for that specific list item). The problem occurs
(inconsistently) when the label capyion changes from item(0) to item(4) and
vice versa? This gives me a data type mismatch error. Here is my code:
>
> Private Sub cmdSubmit_Click()
> Dim lblCaption As Label
> Dim objOptGrp As OptionGroup
> Dim strlabelVal As String
> Dim chkOne, chkTwo, chkThree, chkFour As CheckBox
> Dim rsTicklist As Recordset
> Dim dbsLHSS As Database
> Dim ctl As Control
>
> 'Set dbsLHSS = CurrentDb
> 'Set rsTicklist = dbsLHSS.OpenRecordset("tbl_tickList", dbOpenDynaset,
dbAppendOnly)
>
> For Each ctl In Me.Controls
>     If (ctl.ControlType = acOptionGroup) Then
>         Set objOptGrp = ctl
>         Set lblCaption = objOptGrp.Controls.Item(0)
>         strlabelVal = lblCaption.Caption
>         Debug.Print strlabelVal
>         Set chkOne = objOptGrp.Controls.Item(1)
>         Debug.Print "check 1 " & chkOne.Name '***Just me trying to find
out which list items are causing trouble.
>         Set chkTwo = objOptGrp.Controls.Item(2)
>         Debug.Print "CHECK 2 " & chkTwo.Name
>         Set chkThree = objOptGrp.Controls.Item(3)
>         Debug.Print "CHECK 3 " & chkThree.Name
>         Set chkFour = objOptGrp.Controls.Item(4)
>         Debug.Print "CHECK 4 " & chkFour.Name
>
>         'With rsTicklist
>             '.AddNew
>             '!School = strSchoolName
>             '!Theme = strlabelVal
>             '!DateOfAssessment = dtAssessDate
>             Select Case objOptGrp.Value
>                 Case Is = 1
>                 '!GoodUpToDate = True
>                 MsgBox strlabelVal & " 1st" *****This is just so I can
check the correct options are being submitted
>                 Case Is = 2
>                 '!PartiallyInPlaceWorkPlanned = True
>                 MsgBox strlabelVal & " 2nd"
>                 Case Is = 3
>                 '!DevAreaWorkPlanned = True
>                 MsgBox strlabelVal & " 3rd"
>                 Case Is = 4
>                 '!DevAreaWorkNOTplanned = True
>                 MsgBox strlabelVal & " 4th"
>             End Select
>         'End With
>     End If
> Next ctl
>
> 'rsTicklist.Close
> 'dbsLHSS.Close
> End Sub
>
> any help will be greatly appreciated.


Relevant Pages

  • Re: Controls collection
    ... I need to enumerate the controls of a form and look for property named ... Label or Caption. ... dim s as string ...
    (microsoft.public.vb.controls)
  • Re: Making label caption = table field description
    ... Not sure why you are renaming all the controls. ... > Dim strNConv As String ... >> assigning to the Caption of the attached label. ...
    (microsoft.public.access.formscoding)
  • Re: "Renaming Form Buttons From Macro"
    ... Dim myStartDate As Date ... Caption in the VBE properties window to see if it actually changed it there? ... "Dave Peterson" wrote: ...
    (microsoft.public.excel.programming)
  • Re: "Renaming Form Buttons From Macro"
    ... Caption in the VBE properties window to see if it actually changed it there? ... "Dave Peterson" wrote: ... used myDate in the caption and to compare with the original myStartDate. ... Dim myStartDate As Date ...
    (microsoft.public.excel.programming)
  • Re: Shipping Label Design
    ... BusinessAddressStreet ... After changing the name of the file in the program to .dotx, my template ... Interestingly, when I saved the "label" which I made with your program, it ... It highlighted "Dim oWord As Word.Application" ...
    (microsoft.public.word.docmanagement)