how do i move to another field in a form via goto on a yes/no box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I use Access 2003 and i use forms a lot, i sometimes have lots of different
sections within a database and depending on the answer to the questions i
would like it to move to the next section and fill in the previous fields as
no ie; if the field was do you have a cat was answered no, i would like it to
miss out the fields that were cat part of the section on cats and move on to
the next section/field do you have a dog? and perhaps fill the previous
fields in as no. Can anyone help as i know nothing about visual basic.

Thanks
 
You will have to use a little VBA to accomplish what you want. Using your
example, lets see we have a check box the user checks if he has a cat named
chkCat (the check box, not the cat. The cat's name is Chester) and you have
another for dogs named chkDog (the dog's name is Moe). If you want to skip
other cat questions and go to Do You Have a Do?, then you need the following
in the After Update event of chkCat:

If Me.chkCat = True Then
Me.chkCat.SetFocus
End If
 
Val said:
I use Access 2003 and i use forms a lot, i sometimes have lots of different
sections within a database and depending on the answer to the questions i
would like it to move to the next section and fill in the previous fields
as
no ie; if the field was do you have a cat was answered no, i would like it
to
miss out the fields that were cat part of the section on cats and move on
to
the next section/field do you have a dog? and perhaps fill the previous
fields in as no. Can anyone help as i know nothing about visual basic.

Thanks

One solution would be to use the tag property of the controls, for example
use "cat" for all controls pertaining to cats and then disable the "cat"
tagged controls if the "do you have a cat" answer is "no". For example, if
the question is answered via an option group called "ogrCatOwner", try
something like this in its After Update event (untested):

Dim ctl As Control

If Me.ogrCatOwner = 0 Then
For Each ctl In Me.Controls
If ctl.Tag = "cat" Then ctl.Enabled = False
Next ctl
Else
For Each ctl In Me.Controls
If ctl.Tag = "cat" Then ctl.Enabled = True
Next ctl
End If

This assumes the radio button option for "no" has a value of 0 and that for
"yes" doesn't.

HTH - Keith.
www.keithwilby.com
 
Back
Top