Displaying fields, relevent to selection in a form

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

Guest

title: Displaying fields, relevent to selection in a form

I have been working alongside a college who have a nice looking form built.

The form which is used for data entry, has fields that are relevent to a
delivery. Eg. Delievery data, method, ammount charged for delivery.

We also have a yes/no field that is wether the person has requested a
delivery. We would like just as I have seen on a website before, a way of
only displaying the details that are relevent to the delivery only if the
delivery yes/no check box has it's properties selected as YES (it's been
checked)

Hope you understand what I mean by this, it often happens on a website when
you are asked if your delivery address is the same as the billing address
(that you normally enter first).

If you select "no, my delivery address is different"

The DELIVERY ADDRESS fields and options boxes and other function type things
are then shown below.

I basically want to do this with a few of my fields on my form, but still
want them to be in my table

Thankyou for any help that you can give me

Daniel
 
You can control the visibility of almost any control based on the action of
another control. If you have a check box and you want other controls to show
based on the fact that the user checked the checkbox then you will need to
provide VBA code to perform the action. It does not hurt anything for you to
have controls bound to fields in your table that are not shown on your form
all the time. The fields that are bound to hidden controls will just not
have any opportunity to be filled in.

Te following assumes that your check box is set to be unchecked when the
form opens.

With your form open in design mode, select your check box and right click on
it and select "Properties" to display the "Properties" dialog box.

Click on the "Event" tab. Locate the "After Update" event and place your
cursor in it. Click the button with the down arror and select the only option
which is: "[Event Procedure]". Next click the button with the three dots.

The Visual Basic window will be displayed. You should see something like:
Private Sub YourCheckBoxName_Click()

End Sub

This is where you can put some code to accoumplish what you want. Just above
the "End Sub" type the following (changing the "YourCheckBoxName" to the
actual name you have assigned to your check box and the "NameOfOtherControl"
to the actual name of the control that you want to make visible):

If Me.YourCheckBoxName = true then
Me.NameOfOtherControl.Visible = True
End If

The lines "Me.NameOfOtherControl.Visible = True" can be repeated as many
times as needed, using the name of any other control, to control the
visibility of that control.

One more thing to do: For each control that you want to only be visible if
the user checks the checkbox, select the control and set its visible property
to "No". Save the changes to your form.

If your checkbox is bound to a field in your table so that the value of the
checkbox is stored in your table, you will need to place the same type of
code in the "On Current" event of your form inorder for your controls to be
visible is the status of the checkbox is true when the form opens.
 
I've managed to add a second if, which makes them NOt visable (or
myname.visible = false...)

It's great because it works every time the check box is checked. (wether or
not it starts checked or not)

Do you know how I can add this event procudure to the whole form so that
everytime a record changes it run its?

thanks for your help

Dan

iPod's ROCK!


Mr B said:
You can control the visibility of almost any control based on the action of
another control. If you have a check box and you want other controls to show
based on the fact that the user checked the checkbox then you will need to
provide VBA code to perform the action. It does not hurt anything for you to
have controls bound to fields in your table that are not shown on your form
all the time. The fields that are bound to hidden controls will just not
have any opportunity to be filled in.

Te following assumes that your check box is set to be unchecked when the
form opens.

With your form open in design mode, select your check box and right click on
it and select "Properties" to display the "Properties" dialog box.

Click on the "Event" tab. Locate the "After Update" event and place your
cursor in it. Click the button with the down arror and select the only option
which is: "[Event Procedure]". Next click the button with the three dots.

The Visual Basic window will be displayed. You should see something like:
Private Sub YourCheckBoxName_Click()

End Sub

This is where you can put some code to accoumplish what you want. Just above
the "End Sub" type the following (changing the "YourCheckBoxName" to the
actual name you have assigned to your check box and the "NameOfOtherControl"
to the actual name of the control that you want to make visible):

If Me.YourCheckBoxName = true then
Me.NameOfOtherControl.Visible = True
End If

The lines "Me.NameOfOtherControl.Visible = True" can be repeated as many
times as needed, using the name of any other control, to control the
visibility of that control.

One more thing to do: For each control that you want to only be visible if
the user checks the checkbox, select the control and set its visible property
to "No". Save the changes to your form.

If your checkbox is bound to a field in your table so that the value of the
checkbox is stored in your table, you will need to place the same type of
code in the "On Current" event of your form inorder for your controls to be
visible is the status of the checkbox is true when the form opens.

--
HTH

Mr B


DanielWalters6 said:
title: Displaying fields, relevent to selection in a form

I have been working alongside a college who have a nice looking form built.

The form which is used for data entry, has fields that are relevent to a
delivery. Eg. Delievery data, method, ammount charged for delivery.

We also have a yes/no field that is wether the person has requested a
delivery. We would like just as I have seen on a website before, a way of
only displaying the details that are relevent to the delivery only if the
delivery yes/no check box has it's properties selected as YES (it's been
checked)

Hope you understand what I mean by this, it often happens on a website when
you are asked if your delivery address is the same as the billing address
(that you normally enter first).

If you select "no, my delivery address is different"

The DELIVERY ADDRESS fields and options boxes and other function type things
are then shown below.

I basically want to do this with a few of my fields on my form, but still
want them to be in my table

Thankyou for any help that you can give me

Daniel
 
Try adding your code to the "On current" event of the form. This should
cause the code to run every time the record changes.
--
HTH

Mr B


DanielWalters6 said:
I've managed to add a second if, which makes them NOt visable (or
myname.visible = false...)

It's great because it works every time the check box is checked. (wether or
not it starts checked or not)

Do you know how I can add this event procudure to the whole form so that
everytime a record changes it run its?

thanks for your help

Dan

iPod's ROCK!


Mr B said:
You can control the visibility of almost any control based on the action of
another control. If you have a check box and you want other controls to show
based on the fact that the user checked the checkbox then you will need to
provide VBA code to perform the action. It does not hurt anything for you to
have controls bound to fields in your table that are not shown on your form
all the time. The fields that are bound to hidden controls will just not
have any opportunity to be filled in.

Te following assumes that your check box is set to be unchecked when the
form opens.

With your form open in design mode, select your check box and right click on
it and select "Properties" to display the "Properties" dialog box.

Click on the "Event" tab. Locate the "After Update" event and place your
cursor in it. Click the button with the down arror and select the only option
which is: "[Event Procedure]". Next click the button with the three dots.

The Visual Basic window will be displayed. You should see something like:
Private Sub YourCheckBoxName_Click()

End Sub

This is where you can put some code to accoumplish what you want. Just above
the "End Sub" type the following (changing the "YourCheckBoxName" to the
actual name you have assigned to your check box and the "NameOfOtherControl"
to the actual name of the control that you want to make visible):

If Me.YourCheckBoxName = true then
Me.NameOfOtherControl.Visible = True
End If

The lines "Me.NameOfOtherControl.Visible = True" can be repeated as many
times as needed, using the name of any other control, to control the
visibility of that control.

One more thing to do: For each control that you want to only be visible if
the user checks the checkbox, select the control and set its visible property
to "No". Save the changes to your form.

If your checkbox is bound to a field in your table so that the value of the
checkbox is stored in your table, you will need to place the same type of
code in the "On Current" event of your form inorder for your controls to be
visible is the status of the checkbox is true when the form opens.

--
HTH

Mr B


DanielWalters6 said:
title: Displaying fields, relevent to selection in a form

I have been working alongside a college who have a nice looking form built.

The form which is used for data entry, has fields that are relevent to a
delivery. Eg. Delievery data, method, ammount charged for delivery.

We also have a yes/no field that is wether the person has requested a
delivery. We would like just as I have seen on a website before, a way of
only displaying the details that are relevent to the delivery only if the
delivery yes/no check box has it's properties selected as YES (it's been
checked)

Hope you understand what I mean by this, it often happens on a website when
you are asked if your delivery address is the same as the billing address
(that you normally enter first).

If you select "no, my delivery address is different"

The DELIVERY ADDRESS fields and options boxes and other function type things
are then shown below.

I basically want to do this with a few of my fields on my form, but still
want them to be in my table

Thankyou for any help that you can give me

Daniel
 

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

Back
Top