Conditional Control Visibility

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

Guest

I am just taking my first faltering footsteps in VBA.

I have a combo box from which a medical professional is selected (doctor,
nurse etc). Adjacent to it there is a text box which holds the date on which
this professional was referred to but I only want the control visible when
the combo box is not blank.

The after update procedure I put in the combo box works fine. Coding as
follows:

Private Sub cboReferredTo_AfterUpdate()
If txtReferredTo = Null Then
Me!dteReferredTo.Visible = False
Else
Me!dteReferredTo.Visible = True
End If
End Sub

However, when I exit the record and come back to it the text box is hidden.

I've either put the procedure in the wrong place or I need some further
coding somewhere
 
NewKid,

Put this code in the form's OnCurrent Procedure;

If IsNull(txtReferredTo) Then
Me!dteReferredTo.Visible = False
Else
Me!dteReferredTo.Visible = True
End If

Then call OnCurrent after the cbo update like this:

Private Sub cboReferredTo_AfterUpdate()
Form_Current
End Sub

HTH,
Josh
 
Wow!!!

Didn't even have time for a coffee!!

Absolutely spot on.
--
Many, many thanks and kind regards.

Tony


Joshua A. Booker said:
NewKid,

Put this code in the form's OnCurrent Procedure;

If IsNull(txtReferredTo) Then
Me!dteReferredTo.Visible = False
Else
Me!dteReferredTo.Visible = True
End If

Then call OnCurrent after the cbo update like this:

Private Sub cboReferredTo_AfterUpdate()
Form_Current
End Sub

HTH,
Josh
 
Back
Top