2 Questions For The Experts

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

Guest

Hi there and thanks in advance for your help. I have 2 questions about my
forms that I cannot quite figure out.
1. I have a main form with several fields to fill out (by typing in or using
combo boxes), as well a tab control with 6 tabs on it and on each of the tabs
there is a sub-form. When I choose a value from a combo-box, I want only the
fields that pertain to that value to be enabled on the sub-forms. For
example, if the location is "Babine", I want the "Oversize Tops" field to be
enabled - but if the location is "Decker", I want the "Oversize Tops" field
to be disables. And this applies to several fields on the sub-forms. Can
you please help on this one?

2. I have a field that is a total field for the table that is calculated
based on the other fields on the form. For example, "Total_1_Point_Fines" is
based on the total of 5 other fields on the form. I used the following
expression in its control source
"=([Limbs_debris]+[School_marms]+[Snipes]+[Tops_over]+[Tops_under])" and it
displays on the form properly, but when I look at the table, the value is not
being updated. Any ideas on what I am doing wrong here?

Thanks,
Todd
 
Hi, north-bc.

1. I would set all of the conditionally enabled controls Enabled property to
False in form design view, and, optionally, the Visible property to No. In
the AfterUpdate event procedure of the Location field, the required code is:

Select Case Me!Location
Case "Babine"
' or if there is more than one value for which you'd like to toggle
OversizeTops on
' Case "Babine", "AnotherValue", "YetAnotherValue"
Me![OversizeTops].Enabled = True
' Optional
Me![OversizeTops].Visible = True
End Select

When you go to a new existing record, I assume you'd like the OversizeTops
status to reflect the value in Location. To handle this, in the On Current
event of the form, turn them off if necessary.

Select Case Me!Location
Case "Babine", "AnotherValue", "YetAnotherValue"
Me![OversizeTops].Enabled = True
Me![OversizeTops].Visible = True
Case Else
Me![OversizeTops].Enabled = False
Me![OversizeTops].Visible = False
End Select

Add similar statements for all of the other fields for which this applies.

2. This is a classic question. In almost every case, you don't want to
store a calculation in a field, since it's faster to recalculate on the fly
in a query than to read the value from disk, and you don't risk the
calculated field being out-of-date if someone changes data in one of the
fields out of the context of your form. You'll notice you can either set a
form control's Control Source EITHER to an expression like your calculation
OR to the name of an underlying field. There is no way to do both. The only
way to store a calculation in a field is to have another control bound to the
field, and use VBA to write the value of the calculated control to it. But,
as I said, you're much better off NOT doing that. Since you'll want to print
this value in a report, simply add the field as a calculation in a query, and
base your result on the query.

Hope that helps.
Sprinks

north-bc said:
Hi there and thanks in advance for your help. I have 2 questions about my
forms that I cannot quite figure out.
1. I have a main form with several fields to fill out (by typing in or using
combo boxes), as well a tab control with 6 tabs on it and on each of the tabs
there is a sub-form. When I choose a value from a combo-box, I want only the
fields that pertain to that value to be enabled on the sub-forms. For
example, if the location is "Babine", I want the "Oversize Tops" field to be
enabled - but if the location is "Decker", I want the "Oversize Tops" field
to be disables. And this applies to several fields on the sub-forms. Can
you please help on this one?

2. I have a field that is a total field for the table that is calculated
based on the other fields on the form. For example, "Total_1_Point_Fines" is
based on the total of 5 other fields on the form. I used the following
expression in its control source
"=([Limbs_debris]+[School_marms]+[Snipes]+[Tops_over]+[Tops_under])" and it
displays on the form properly, but when I look at the table, the value is not
being updated. Any ideas on what I am doing wrong here?

Thanks,
Todd
 
Back
Top