Skipping over a section of a form

R

ronben

Version: 2004 Operating System: Mac OS X 10.4 (Tiger) Processor: Intel My previous post on this problem seems to have terminated. I am still stuck on this. I have simplified the issue as follows: The form has several form fields. Interposed between these form fields is a question asking: Check the box if you want to skip the next field (and go on to a field further down)?

The checkbox is set to run the macro below on exit. I assume that placing an X in the box triggers the Exit macro, but that does not seem to work. This is the macro code:

If Check1 = True Then
 'skip over Text3 and go to Text4
  Selection.GoTo What:=wdGoToBookmark, Name:="Text4"
Else
  'checkbox not checked; do not skip over Text3
  Selection.GoTo What:=wdGoToBookmark, Name:="Text3"
End If

Comment re the above exit macro:
The macro above was set to run on Exit with the intent that the If….Then statement would test the value of the checkbox and trigger skipping over the next section of the form if the checkbox is checked by hitting the space bar. However, this did not happen. The insertion moves into the next section of the form anyway rather than skipping over it.

(When I click on VB Help I get a message that the Help file cannot be found so I am hoping that the forum can help with this problem. Thanks.)

Ron
 
J

John McGhie

Hi Ron:

You are still coding "If Check1 = True"

It always will be True, because Check1 is the checkbox control itself. That
contains something (a checkbox) so it's value is NOT "nothing" and
therefore, is true always.

You need to say "If Check1.Value = True then" which tests the Value property
that Check1 contains. That will toggle between True and False depending on
what the user does. Check1 has several other properties as well: for
example, its name. But there is only one .Value.

Did you look at the examples I referred you to?

Cheers


Version: 2004 Operating System: Mac OS X 10.4 (Tiger) Processor: Intel My
previous post on this problem seems to have terminated. I am still stuck on
this. I have simplified the issue as follows: The form has several form
fields. Interposed between these form fields is a question asking: Check the
box if you want to skip the next field (and go on to a field further down)?

The checkbox is set to run the macro below on exit. I assume that placing an
X in the box triggers the Exit macro, but that does not seem to work. This is
the macro code:

If Check1 = True Then
'skip over Text3 and go to Text4
Selection.GoTo What:=wdGoToBookmark, Name:="Text4"
Else
'checkbox not checked; do not skip over Text3
Selection.GoTo What:=wdGoToBookmark, Name:="Text3"
End If

Comment re the above exit macro:
The macro above was set to run on Exit with the intent that the If….Then
statement would test the value of the checkbox and trigger skipping over the
next section of the form if the checkbox is checked by hitting the space bar.
However, this did not happen. The insertion moves into the next section of the
form anyway rather than skipping over it.

(When I click on VB Help I get a message that the Help file cannot be found so
I am hoping that the forum can help with this problem. Thanks.)

Ron

This email is my business email -- Please do not email me about forum
matters unless you intend to pay!

--

John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. | Ph: +61 (0)4 1209 1410
+61 4 1209 1410, mailto:[email protected]
 
J

Jim Gordon Mac MVP

Version: 2004 Operating System: Mac OS X 10.4 (Tiger) Processor: Intel
My previous post on this problem seems to have terminated. I am still
stuck on this. I have simplified the issue as follows: The form has
several form fields. Interposed between these form fields is a question
asking: Check the box if you want to skip the next field (and go on to a
field further down)?

The checkbox is set to run the macro below on exit. I assume that
placing an X in the box triggers the Exit macro, but that does not seem
to work. This is the macro code:

If Check1 = True Then
'skip over Text3 and go to Text4
Selection.GoTo What:=wdGoToBookmark, Name:="Text4"
Else
'checkbox not checked; do not skip over Text3
Selection.GoTo What:=wdGoToBookmark, Name:="Text3"
End If

Comment re the above exit macro:
The macro above was set to run on Exit with the intent that the If….Then
statement would test the value of the checkbox and trigger skipping over
the next section of the form if the checkbox is checked by hitting the
space bar. However, this did not happen. The insertion moves into the
next section of the form anyway rather than skipping over it.

(When I click on VB Help I get a message that the Help file cannot be
found so I am hoping that the forum can help with this problem. Thanks.)

Ron

Clicking in the box to place the X does not trigger the macro. Pressing
the TAB key to move to the next form field triggers the macro.

-Jim
 
R

ronben

Hi Ron:
>
> You are still coding "If Check1 = True"
>
> It always will be True, because Check1 is the checkbox control itself. That
> contains something (a checkbox) so it's value is NOT "nothing" and
> therefore, is true always.
>
> You need to say "If Check1.Value = True then" which tests the Value property
> that Check1 contains. That will toggle between True and False depending on
> what the user does. Check1 has several other properties as well: for
> example, its name. But there is only one .Value.
>
> Did you look at the examples I referred you to?
>
> Cheers
>
>
> On 22/12/09 10:51 PM, in article (e-mail address removed)2ac0,
> "[email protected]" wrote:
>
>
> This email is my business email -- Please do not email me about forum
> matters unless you intend to pay!
>
> --
>
> John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
> McGhie Information Engineering Pty Ltd
> Sydney, Australia. | Ph: +61 (0)4 1209 1410
> +61 4 1209 1410, mailto:[email protected]
>
> Thanks, John:

I read all of Dian Chapman's articles. Still, the compiler is showing no mercy despite attempting to use your suggestion above (and Dian's code). I get a runtime 424 error. Also get Sub or Function not defined error. I tried to define a variable to take on the value of the checkbox.

One iteration goes like this:

Dim vChk Boolean
'''
vChk = ActiveDocument.Bookmarks("Check1").value

this did not work either.

I have tried many different permutations of the statements in this macro and have yet to get it to work. I have looked at a VBA for Dummies book (am feeling very much like a dummy) but it seems more oriented to Office applications for Windows rather than the Mac. I have the impression that VBA Office for the Mac is a somewhat different flavor. I do not seem to have the VB help files installed and I will have to find the CD. So, still no luck.

Still pluggine away here...
 
R

ronben

> > Version: 2004 Operating System: Mac OS X 10.4 (Tiger) Processor: Intel
> > My previous post on this problem seems to have terminated. I am still
> > stuck on this. I have simplified the issue as follows: The form has
> > several form fields. Interposed between these form fields is a question
> > asking: Check the box if you want to skip the next field (and go on to a
> > field further down)?
> >
> > The checkbox is set to run the macro below on exit. I assume that
> > placing an X in the box triggers the Exit macro, but that does not seem
> > to work. This is the macro code:
> >
> > If Check1 = True Then
> > 'skip over Text3 and go to Text4
> > Selection.GoTo What:=wdGoToBookmark, Name:="Text4"
> > Else
> > 'checkbox not checked; do not skip over Text3
> > Selection.GoTo What:=wdGoToBookmark, Name:="Text3"
> > End If
> >
> > Comment re the above exit macro:
> > The macro above was set to run on Exit with the intent that the If�.Then
> > statement would test the value of the checkbox and trigger skipping over
> > the next section of the form if the checkbox is checked by hitting the
> > space bar. However, this did not happen. The insertion moves into the
> > next section of the form anyway rather than skipping over it.
> >
> > (When I click on VB Help I get a message that the Help file cannot be
> > found so I am hoping that the forum can help with this problem. Thanks.)
> >
> > Ron
>
> Clicking in the box to place the X does not trigger the macro. Pressing
> the TAB key to move to the next form field triggers the macro.
>
> -Jim
>
> --
> Jim Gordon
> Mac MVP
> Co-author of Office 2008 for Mac All-in-One For Dummies
> http://tinyurl.com/Office-2008-for-Dummies
>

Jim, thanks. As you can see from my reply to John McGhie, success has not come my way (only very cold weather via the Alberta clipper).

Ron
 
J

John McGhie

Hi Ron:

Flip me a copy of the document you're working in, and the template you have
the macro in. I'll take a look for you. Email in the .sig

(not: Plain text email with attachments: no urls or you won't make it
through the spam filter...)

You're getting "out of context" errors which means you either have the macro
in the wrong place, or defined as Private when it should be Public.

VBA in Word is VBA in Word, regardless of the platform. It's just that not
all of it "works" on the Mac (but it is supposed to...)

Cheers

I read all of Dian Chapman's articles. Still, the compiler is showing no
mercy despite attempting to use your suggestion above (and Dian's code). I
get a runtime 424 error. Also get Sub or Function not defined error. I tried
to define a variable to take on the value of the checkbox.

One iteration goes like this:

Dim vChk Boolean
'''
vChk = ActiveDocument.Bookmarks("Check1").value

this did not work either.

I have tried many different permutations of the statements in this macro and
have yet to get it to work. I have looked at a VBA for Dummies book (am
feeling very much like a dummy) but it seems more oriented to Office
applications for Windows rather than the Mac. I have the impression that VBA
Office for the Mac is a somewhat different flavor. I do not seem to have the
VB help files installed and I will have to find the CD. So, still no luck.

Still pluggine away here...

This email is my business email -- Please do not email me about forum
matters unless you intend to pay!

--

John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. | Ph: +61 (0)4 1209 1410
+61 4 1209 1410, mailto:[email protected]
 
J

Jim Gordon Mac MVP

Jim, thanks. As you can see from my reply to John McGhie, success has
not come my way (only very cold weather via the Alberta clipper).

Ron

Hi Ron,

When you are in the VB Editor the help files that are available are
different from when you are not int he VB editor. Here's a slight
modification of your code blended with the example provided by the Help
in the VB Editor. This code works when I press the Tab key while the
form is protected for forms. The default setting for Check1 is not
checked (set this in the form's dialog box before protecting the form).
Adjust the true/false logic as desired. I used different bookmark names
from yours for no reason in particular - just felt like it.

Sub HandleCheckbox()
Dim Check1, Same, MyField
Set MyField = ActiveDocument.FormFields("Check1").CheckBox
If MyField.Default = MyField.Value Then Same = True
If Same = True Then
'skip over Text3 and go to Text4
Selection.GoTo What:=wdGoToBookmark, Name:="FirstBookmark"
MsgBox "FirstBookmark selected"
Else
'checkbox not checked; do not skip over Text3
Selection.GoTo What:=wdGoToBookmark, Name:="SecondBookmark"
MsgBox "SecondBookmark selected"
End If
End Sub

-Jim
 
R

ronben

Jim,
I finally got your code snippet to work, once I got the checked-unchecked logic squared away.

Thanks,
Ron
 

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

Top