pop up a form based on a check box

  • Thread starter Thread starter Dave Bernarducci
  • Start date Start date
D

Dave Bernarducci

I'm a novice and need a simple way to request additional
data based on the status of a check box.

For example, if the user checks the box labeled "Ice
Cream?" I then want to provide them with a list of other
checkboxes ("sprinkles?", "whipped cream?", etc.).
I don't want these additional checkboxes available if they
have not checked the ice cream box.

What is the easiest way to make the additional boxes
available for input when needed?

Thanks!!!

Dave
 
You can set the Sprinkles and Whipped Cream checkboxes Enabled property to
False in your form's design. This displays them "greyed out" providing
instant visual feedback to your users that they are not available. Then, in
the After Update event of the Ice Cream checkbox, you can reset the Enabled
property of the other checkboxes to True, as in the following example:

If Me!chkIceCream = True then
Me!chkSprinkles.Enabled = True
Me!chkWhippedCream.Enabled = True
else
Me!chkSprinkles.Enabled = False
Me!chkWhippedCream.Enabled = False
End If


hth,
 
Hi Dave:

In the AFTER UPDATE event:
If chkIceCream Then
me.Sprinkles.visible = true
me.WhippedCream.visible = True
End if
This assumes the other checkboxes are on the same form.

Hope this helps
 
Thanks to both of you!!

I probably should have mentioned that i created the entire
database w/o using any code - I just used all the features
of the GUI.
I'm assuming that the text you sent is visual basic (or
does this code just get entered using the expression
builder?)? What is the best way to start with this? Do I
create a "module" and run it After Entry?

Also, what happens if the checkbox is already checked when
the form opens? Won't the other boxes remain gray until
you uncheck and check it again?

Thanks again!!
 
Dave,
I probably should have mentioned that i created the entire
database w/o using any code - I just used all the features
of the GUI.

That's fine! However, when you want to move beyond "the basics", using code
is the recommended next step and often is the only way to get what you want.
I'm assuming that the text you sent is visual basic (or
does this code just get entered using the expression
builder?)? What is the best way to start with this? Do I
create a "module" and run it After Entry?

The code is often referred to as "visual basic"; more correctly, it is VBA
or Visual Basic for Applications. For the purpose you describe, you would
use the code module which is already available to you in your Form. Here is
how to insert the code I provided:

Open your form in Design View, then:

1. Right-click on your IceCream checkbox. Select "Properties".

2. In the popup window that opens, you will see a set of Tabs. Click the
one that says "Events".

3. In the grid below, locate the row labeled, After Update. It should be
blank. Click anywhere in the white space to the right of the label and you
will see a downward-pointing arrow appear, indicating that this is also a
ComboBox. Click the arrow and select "Event Procedure".

4. Then, notice that there is an ellipsis or three little dots (...) to the
right of the ComboBox. Click the ellipsis and you will open a code window.
You will see that Access has given you a space for entering some code in
this event - it will look something like the following:

Private Sub chkIceCream_BeforeUpdate(Cancel As Integer)

End Sub

5. After the "Private Sub chkIceCream_BeforeUpdate(Cancel As Integer)"
line, insert the following code:

If Me!chkIceCream = True then
Me!chkSprinkles.Enabled = True
Me!chkWhippedCream.Enabled = True
else
Me!chkSprinkles.Enabled = False
Me!chkWhippedCream.Enabled = False
End If

Save the module. Then, click on the Debug menu item in the code window and
select Debug. If the debug produces no errors, just close the module.
Also, what happens if the checkbox is already checked when
the form opens? Won't the other boxes remain gray until
you uncheck and check it again?

Good point. You would insert the code I gave you into the Form's Current
event.

hth,
 
bingo

THANKS!!
-----Original Message-----
Dave,


That's fine! However, when you want to move beyond "the basics", using code
is the recommended next step and often is the only way to get what you want.


The code is often referred to as "visual basic"; more correctly, it is VBA
or Visual Basic for Applications. For the purpose you describe, you would
use the code module which is already available to you in your Form. Here is
how to insert the code I provided:

Open your form in Design View, then:

1. Right-click on your IceCream checkbox. Select "Properties".

2. In the popup window that opens, you will see a set of Tabs. Click the
one that says "Events".

3. In the grid below, locate the row labeled, After Update. It should be
blank. Click anywhere in the white space to the right of the label and you
will see a downward-pointing arrow appear, indicating that this is also a
ComboBox. Click the arrow and select "Event Procedure".

4. Then, notice that there is an ellipsis or three little dots (...) to the
right of the ComboBox. Click the ellipsis and you will open a code window.
You will see that Access has given you a space for entering some code in
this event - it will look something like the following:

Private Sub chkIceCream_BeforeUpdate(Cancel As Integer)

End Sub

5. After the "Private Sub chkIceCream_BeforeUpdate (Cancel As Integer)"
line, insert the following code:

If Me!chkIceCream = True then
Me!chkSprinkles.Enabled = True
Me!chkWhippedCream.Enabled = True
else
Me!chkSprinkles.Enabled = False
Me!chkWhippedCream.Enabled = False
End If

Save the module. Then, click on the Debug menu item in the code window and
select Debug. If the debug produces no errors, just close the module.


Good point. You would insert the code I gave you into the Form's Current
event.

hth,


--
Cheryl Fischer
Law/Sys Associates
Houston, TX




.
 
Back
Top