Re: error on dim

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Doug Robbins - Word MVP (dkr_at_NOmvpsSPAM.org)
Date: 04/13/04


Date: Tue, 13 Apr 2004 17:56:13 +1000

Hi Phil,

Send me a copy of the template and I'll take a look at it.

--
Regards,
Doug Robbins - Word MVP
"phil" <pwbga@bigpond.com> wrote in message
news:Oid2X0OIEHA.1944@TK2MSFTNGP11.phx.gbl...
> hi doug
> no errors now but checkboxes are not checking
> any ideas
> thanks phil
> "Doug Robbins - Word MVP" <dkr@NOmvpsSPAM.org> wrote in message
> news:%23Yx8bDJIEHA.3248@TK2MSFTNGP12.phx.gbl...
> > Hi Phil,
> >
> > Sorry, I had a typo there.  The "th" should have been "tb" based on your
> > post of yesterday.
> >
> > As far as the checkboxes are concerned, I not that you are checking
> > Left(mycontrol.Name, 5) to see if it is "chter"  Maybe the next line
> should
> > be
> >
> > myformfield = "Check" & Mid(mycontrol.Name, 6)
> >
> > rather than
> >
> > myformfield = "Check" & Mid(mycontrol.Name, 7)
> >
> > --
> > Please post any further questions or followup to the newsgroups for the
> > benefit of others who may be interested.  Unsolicited questions
forwarded
> > directly to me will only be answered on a paid consulting basis.
> >
> > Hope this helps
> > Doug Robbins - Word MVP
> > "phil" <pwbga@bigpond.com> wrote in message
> > news:OWvN$VHIEHA.3968@TK2MSFTNGP12.phx.gbl...
> > > hi doug
> > > i'm having problems with the checkboxes not checking an error comes up
> > the
> > > requested member does not exist this happens on
> > > "ActiveDocument.FormFields(myformffield).CheckBox.Value = True"
> > > the first section of the code works fine
> > > i aslo took out the line "   If Left(mycontrol.Name, 2) = "th" Then"
> > > this was causing problems with the bookmarks not updating
> > > thanks phil
> > >
> > > Dim mycontrol As Control, myformfield As String, BMRange As Range
> > >     For Each mycontrol In Me.Controls
> > >             myformfield = "bm" & Mid(mycontrol.Name, 3)
> > >             If ActiveDocument.Bookmarks.Exists(myformfield) = True
Then
> > >                 Set BMRange =
> ActiveDocument.Bookmarks(myformfield).Range
> > >                 BMRange.Text = mycontrol
> > >             ActiveDocument.Bookmarks.Add myformfield, BMRange
> > >         ElseIf Left(mycontrol.Name, 5) = "chter" Then
> > >             myformfield = "Check" & Mid(mycontrol.Name, 7)
> > >             If ActiveDocument.Bookmarks.Exists(myformfield) = True
Then
> > >                  If mycontrol = True Then
> > >
> > ActiveDocument.FormFields(myformffield).CheckBox.Value
> > > = True
> > >                  Else
> > >
> ActiveDocument.FormFields(myformfield).CheckBox.Value
> > =
> > > False
> > >                  End If
> > >             End If
> > >         End If
> > >     Next
> > > Me.hide
> > > "Doug Robbins - Word MVP" <dkr@NOmvpsSPAM.org> wrote in message
> > > news:OwLCncEIEHA.2744@TK2MSFTNGP10.phx.gbl...
> > > > Hi Phil.
> > > >
> > > > i has already be Declared so you cannot declare it a second time.
As
> > you
> > > > are not using it, you can delete it for both sets of declarations
> (Dim).
> > > > It's really best to declare all of the variables at the beginning of
> the
> > > > procedure rather than to have them scattered through it was you
have.
> > > >
> > > > The following should do what you want:
> > > >
> > > > Dim mycontrol As Control, myformfield As String, BMRange As range
> > > >     For Each mycontrol In Me.Controls
> > > >         If Left(mycontrol.Name, 2) = "th" Then
> > > >             myformfield = "bm" & Mid(mycontrol.Name, 3)
> > > >             If ActiveDocument.Bookmarks.Exists(myformfield) = True
> Then
> > > >                 Set BMRange =
> > ActiveDocument.Bookmarks(myformfield).range
> > > >                 BMRange.Text = mycontrol
> > > >             ActiveDocument.Bookmarks.Add myformfield, BMRange
> > > >         ElseIf Left(mycontrol.Name, 5) = "chter" Then
> > > >             myformfield = "Check" & Mid(mycontrol.Name, 7)
> > > >             If ActiveDocument.Bookmarks.Exists(myformfield) = True
> Then
> > > >                  If mycontrol = True Then
> > > >
> > > ActiveDocument.FormFields(myformffield).CheckBox.Value
> > > > = True
> > > >                  Else
> > > >
> > ActiveDocument.FormFields(myformfield).CheckBox.Value
> > > =
> > > > False
> > > >                  End If
> > > >         End If
> > > >     Next
> > > > Me.hide
> > > >
> > > >
> > > > --
> > > > Please post any further questions or followup to the newsgroups for
> the
> > > > benefit of others who may be interested.  Unsolicited questions
> > forwarded
> > > > directly to me will only be answered on a paid consulting basis.
> > > >
> > > > Hope this helps
> > > > Doug Robbins - Word MVP
> > > > "phil" <pwbga@bigpond.com> wrote in message
> > > > news:OzcY2mCIEHA.3720@tk2msftngp13.phx.gbl...
> > > > > both of these code are placed into one command button and an error
> > > occurs
> > > > > because of the repeating of the code
> > > > > I assume I need to separate these codes but am not sure where to
put
> > the
> > > > > removed code
> > > > > I only have one command button in the userform and don't really
want
> > > > > another
> > > > > can someone help me out
> > > > > thanks phil
> > > > >
> > > > >  Dim i As Long, mycontrol As Control, myformfield As String
> > > > >    For Each mycontrol In Me.Controls
> > > > >       myformfield = "bm" & Mid(mycontrol.Name, 3)
> > > > >            Dim BMRange As Range
> > > > >                If ActiveDocument.Bookmarks.Exists(myformfield) =
> True
> > > Then
> > > > >                    Set BMRange =
> > > > > ActiveDocument.Bookmarks(myformfield).Range
> > > > >                BMRange.Text = mycontrol
> > > > >            ActiveDocument.Bookmarks.Add myformfield, BMRange
> > > > >        End If
> > > > >    Next
> > > > > Me.hide
> > > > >
> > > > >  Dim i As Long, chk As Control, ffcheck As String
> > > > >     For Each chk In Me.Controls
> > > > >         If Left(chk.Name, 5) = "chter" Then
> > > > >             ffcheck = "Check" & Mid(chk.Name, 7)
> > > > >             If ActiveDocument.Bookmarks.Exists(ffcheck) = True
Then
> > > > >                 If chk = True Then
> > > > >
> ActiveDocument.FormFields(ffcheck).CheckBox.Value
> > =
> > > > > True
> > > > >                 Else
> > > > >
> ActiveDocument.FormFields(ffcheck).CheckBox.Value
> > =
> > > > > False
> > > > >                 End If
> > > > >              End If
> > > > >         End If
> > > > >
> > > > >     Next
> > > > >     Me.hide
> > > > >
> > > > >
> > > >
> > >
> > >
> >
>
>

Quantcast