Correct visibility of fields on form depending on conditions

S

Sammie

I have 3 conditions which affect the visibility of fields on a form.
Which form event will check these conditons and display the 3 fields
correctly as I move from record to record? Right now I have these
procedures running on the form after update event, but it doesn't work
if I don't update the record I'm leaving.

Field properties on form:
Shipping.visible = true
TotalCIP.visible = true
CollectShipAct.Visible = false

Form after update statement (only 1 of these 3 conditions can be true at
a time based on field after update events):

'For FOB shipments, make shipping and CIP lines invisible
If Shipped_FOB = -1 Then
Shipping.Visible = False
TotalCIP.Visible = False
End If

'For CIP shipments, make shipping and CIP lines invisible
If Shipped_CIP = -1 Then
Shipping.Visible = False
TotalCIP.Visible = False
End If

'For collect shipments, make shipping and CIP lines invisible
and also Display ship acct no.
If Shipped_Collect = -1 Then
Shipping.Visible = False
TotalCIP.Visible = False
CollectShipAct.Visible = True
End If

End Sub

I'm beginning to wonder if it's even possible, and the logic sends me
around in circles. Maybe that's what's happening to Access, too!

By the way, I need to make these same conditions work on a report based
on this form. Please comment if this is possible, too.

Thanks.
Sammie
 
A

Allen Browne

The basic idea would be to use the AfterUpdate event of the checkboxes(?) to
set the Visible properties of the controls. Also call the code in the
Current event of the form (so it runs when you move record), and also the
Undo event of the form (so it is reset correctly depending on the OldValue).

It looks like you have 3 yes/no fields, and you are trying to ensure that
the user can check only one. Would it be better to use a single Number field
instead of the 3 yes/no fields? You could then use an option group with 3
check boxes it in, and then whenever the user checks one the others become
unchecked.
 
S

Sammie

Allen said:
The basic idea would be to use the AfterUpdate event of the checkboxes(?) to
set the Visible properties of the controls. Also call the code in the
Current event of the form (so it runs when you move record), and also the
Undo event of the form (so it is reset correctly depending on the OldValue).

It looks like you have 3 yes/no fields, and you are trying to ensure that
the user can check only one. Would it be better to use a single Number field
instead of the 3 yes/no fields? You could then use an option group with 3
check boxes it in, and then whenever the user checks one the others become
unchecked.
WOW! This was VERY helpful. Thank you. I had forgotten all about
option buttons! You have simplified everything.
Sammie
 

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