Can I get fields in my form to appear depending on other fields?

G

Guest

On my form I have many qustions/fields that I require information on.
However I find myself inputting N/A to alot of the questions as the questions
are not applicable. After some analysis, I have found that I can ask one
question at the very start "Pricing Error?", then depending on the answer to
this, the other questions become more relevent. For example, the questions
"Did withdrawing investors benefit?" and "Did contributing investors
benefit?" are only valid if the answer to "Pricing Error?" is "Yes".
Otherwise I would like the user to not be able to put any data into these
fields. Any ideas?
 
K

kingston via AccessMonster.com

Use the trigger control's AfterUpdate event (and the form's OnCurrent event)
to turn the visibility property on or off:

If Me.Control = SpecialValue Then
Me.OtherControl.Visible = False
Else
Me.OtherControl.Visible = True
End If
 
G

Guest

Can you talk me through that in idiots terms? This is how i interpret it
(based on the controls I listed earlier........

If Me.Pricing_Error? = Yes Then
Me.Did_contributing_investors_benefit?.Visible = False
Else
Me.Did_withdrawing_investors_benefit?.Visible = True

This means that if the user selects Yes to the Pricing Error? question, the
Did contributing investors benefit? question will remain invisible, but the
Did withdrawing investors benefit? question will become visible?
 
K

kingston via AccessMonster.com

Open your form in design mode and select the control for Pricing_Error. Open
the Properties window of the control and take a note of the control's name in
the Other tab. Go to the Event tab and in the After Update section, select
[Event Procedure]. Click the small ... button at the end of the entry. A VB
window will open. Add the code with the correct control names and test the
result. One thing I'm concerned about is the ? in the control names you've
provided as examples. I would change the control names and make them simpler.
Also, use the value -1 instead of Yes and True; use 0 for No and False.

If this works, do the same thing for the form and its OnCurrent event.
Can you talk me through that in idiots terms? This is how i interpret it
(based on the controls I listed earlier........

If Me.Pricing_Error? = Yes Then
Me.Did_contributing_investors_benefit?.Visible = False
Else
Me.Did_withdrawing_investors_benefit?.Visible = True

This means that if the user selects Yes to the Pricing Error? question, the
Did contributing investors benefit? question will remain invisible, but the
Did withdrawing investors benefit? question will become visible?
Use the trigger control's AfterUpdate event (and the form's OnCurrent event)
to turn the visibility property on or off:
[quoted text clipped - 14 lines]
 
G

Guest

Rather than make the control invisible, can I just dim it so that the user
knows it is there, but it will be obvious that it is not for populating?

Where can I get help in writing code like this?

kingston via AccessMonster.com said:
Open your form in design mode and select the control for Pricing_Error. Open
the Properties window of the control and take a note of the control's name in
the Other tab. Go to the Event tab and in the After Update section, select
[Event Procedure]. Click the small ... button at the end of the entry. A VB
window will open. Add the code with the correct control names and test the
result. One thing I'm concerned about is the ? in the control names you've
provided as examples. I would change the control names and make them simpler.
Also, use the value -1 instead of Yes and True; use 0 for No and False.

If this works, do the same thing for the form and its OnCurrent event.
Can you talk me through that in idiots terms? This is how i interpret it
(based on the controls I listed earlier........

If Me.Pricing_Error? = Yes Then
Me.Did_contributing_investors_benefit?.Visible = False
Else
Me.Did_withdrawing_investors_benefit?.Visible = True

This means that if the user selects Yes to the Pricing Error? question, the
Did contributing investors benefit? question will remain invisible, but the
Did withdrawing investors benefit? question will become visible?
Use the trigger control's AfterUpdate event (and the form's OnCurrent event)
to turn the visibility property on or off:
[quoted text clipped - 14 lines]
Otherwise I would like the user to not be able to put any data into these
fields. Any ideas?
 
K

kingston via AccessMonster.com

Try using the control properties Enabled or Locked instead of Visible.
Rather than make the control invisible, can I just dim it so that the user
knows it is there, but it will be obvious that it is not for populating?

Where can I get help in writing code like this?
Open your form in design mode and select the control for Pricing_Error. Open
the Properties window of the control and take a note of the control's name in
[quoted text clipped - 25 lines]
 
G

Guest

Thanks for your help Kingston. I have run into problems though. This is my
Visual Basic code;

Private Sub Was_there_a_financial_impact_AfterUpdate()
If Me.Was_there_a_financial_impact = False Then
Else
Me.Did_Contributing_Investors_benefit.Enabled = False
Me.Did_withdrawing_investors_benefit.Enabled = False
Me.Compensation_amount.Enabled = False
Me.Cost_to_correct_Fund_position.Enabled = False
Me.Date_received__Finance_.Enabled = False
Me.Did_Contributing_Investors_benefit.Enabled = False
Me.Did_withdrawing_investors_benefit.Enabled = False
Me.Direct_Financial_Impact_Classification.Enabled = False
Me.Do_clients_need_compensated.Enabled = False
Me.Do_funds_need_compensated.Enabled = False
Me.Authorised_by__comp_.Enabled = False
Me.Received_by__Finance_.Enabled = False
Me.Source_of_Recovery.Enabled = False
Me.Indirect_Financial_Impact_Classification.Enabled = False
Me.Was_impact_over_half__.Enabled = False
Me.Total_cost_of_Event.Enabled = False
Me.Total_cost_to_SLI_of_Event.Enabled = False
Me.Financial_Impact.Enabled = False
Me.Total_client_compensation.Enabled = False
Me.Total_fund_compensation.Enabled = False
End If
End Sub

The field "Was there a financial impact" is a drop down box that allows the
user to choose between; Yes, No, TBC. If they choose No, I want the other
field to not be enabled.

When I go back into the form and input data, I get the Visual Basic window
pop up, with the error message "Compile Error - Method or Data member not
found".

Any advice?


kingston via AccessMonster.com said:
Try using the control properties Enabled or Locked instead of Visible.
Rather than make the control invisible, can I just dim it so that the user
knows it is there, but it will be obvious that it is not for populating?

Where can I get help in writing code like this?
Open your form in design mode and select the control for Pricing_Error. Open
the Properties window of the control and take a note of the control's name in
[quoted text clipped - 25 lines]
Otherwise I would like the user to not be able to put any data into these
fields. Any ideas?
 
K

kingston via AccessMonster.com

The value returned by Was_there_a_financial_impact can only be "Yes", "No",
or "TBC"; it cannot be False. Note the use of quotation marks.

Also, your If statement doesn't seem quite finished:
If Me... = "No" Then
...disable controls...
Else
...enable controls...
End If
Thanks for your help Kingston. I have run into problems though. This is my
Visual Basic code;

Private Sub Was_there_a_financial_impact_AfterUpdate()
If Me.Was_there_a_financial_impact = False Then
Else
Me.Did_Contributing_Investors_benefit.Enabled = False
Me.Did_withdrawing_investors_benefit.Enabled = False
Me.Compensation_amount.Enabled = False
Me.Cost_to_correct_Fund_position.Enabled = False
Me.Date_received__Finance_.Enabled = False
Me.Did_Contributing_Investors_benefit.Enabled = False
Me.Did_withdrawing_investors_benefit.Enabled = False
Me.Direct_Financial_Impact_Classification.Enabled = False
Me.Do_clients_need_compensated.Enabled = False
Me.Do_funds_need_compensated.Enabled = False
Me.Authorised_by__comp_.Enabled = False
Me.Received_by__Finance_.Enabled = False
Me.Source_of_Recovery.Enabled = False
Me.Indirect_Financial_Impact_Classification.Enabled = False
Me.Was_impact_over_half__.Enabled = False
Me.Total_cost_of_Event.Enabled = False
Me.Total_cost_to_SLI_of_Event.Enabled = False
Me.Financial_Impact.Enabled = False
Me.Total_client_compensation.Enabled = False
Me.Total_fund_compensation.Enabled = False
End If
End Sub

The field "Was there a financial impact" is a drop down box that allows the
user to choose between; Yes, No, TBC. If they choose No, I want the other
field to not be enabled.

When I go back into the form and input data, I get the Visual Basic window
pop up, with the error message "Compile Error - Method or Data member not
found".

Any advice?
Try using the control properties Enabled or Locked instead of Visible.
[quoted text clipped - 8 lines]
 

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