Label visability changes

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

Dave

Access 2003

I have a label that I want to hide based upon certain conditions.

Those conditions are that 3 check box fields are checked (true). All 3 must
be checked for the label to NOT be visible.

There is a drop down on the same form that allows you to navigate records.

I am trying to code this on the Update event of that drop down (And I am
guessing there are other places I will need this code.

This is what I am trying (for just one being checked) but it does not seem
to work consistently)

Private Sub cboSearchByName_AfterUpdate()

If Transcripts = True Then
lblconditional.Visible = False
Else
lblconditional.Visible = True
End If
End Sub

The other 2 fields that need to be true are
Application = True
Agreement = true

Can someone help me code this properly

Thanks

Dave
 
Dave said:
Access 2003

I have a label that I want to hide based upon certain conditions.

Those conditions are that 3 check box fields are checked (true). All 3
must be checked for the label to NOT be visible.

There is a drop down on the same form that allows you to navigate records.

I am trying to code this on the Update event of that drop down (And I am
guessing there are other places I will need this code.

This is what I am trying (for just one being checked) but it does not seem
to work consistently)

Private Sub cboSearchByName_AfterUpdate()

If Transcripts = True Then
lblconditional.Visible = False
Else
lblconditional.Visible = True
End If
End Sub

The other 2 fields that need to be true are
Application = True
Agreement = true

Can someone help me code this properly


I wouldn't focus on the combo box. Instead, I would use the form's Current
event -- to handle all forms of record navigation -- as well as the
AfterUpdate events of each of the check boxes. To simplify this, write a
function in the General section of the form's module, like this:

'----- start of code -----
Private Function SetConditionalVisibility()

Me.lblConditional.Visible = _
Not ((Me!Transcripts) And (Me!Application) And (Me!Agreement))

End Sub
'----- end of code -----

Note, by the way, that your use of the reserved word "Application" as the
name for one of your check boxes means that we must be very careful to refer
to it using the bang (!) syntax, not the (.) syntax, and we *must* qualify
it with a reference to the form (Me). That's because the form has an
Application property.

Anyway, with that function in the form's module, now you can call it from an
event procedure for the form's Current event:

'----- start of code for Current event -----
Private Sub Form_Current()

SetConditionalVisibility

End Sub
'----- end of code for Current event -----

You must also call it from the AfterUpdate events of each of the check
boxes. If you have nothing else to do in these events, you don't have to
build three separate event procedures. Instead, you can set the AfterUpdate
event *property* of each control (right on the property sheet) to this
function expression:

=SetConditionalVisibility()

If I've understood what you want, that ought to take care of it.
 
Dirk,

The use of the field "application" was causing me much grief :(
Thanks for pointing out it was a reserved name.
All problems solved now.

Thanks
dave
 
Back
Top