Visible field only works after reset

  • Thread starter Thread starter dbl
  • Start date Start date
D

dbl

Hi I have entered the following code (thanks to the help of Grep)
on my Incident Data Form

Private Sub Form_Current()
If IsNull(txtInFo) Then
txtInFo.Visible = False
Else
txtInFo.Visible = True
End If
End Sub

The txtInFo field only becomes visible after you use reset or you go out of
the record and back into it.

I need it to work as a prompt when you select an Employer if the txtInFo
field has data in it, then the txtInFo field must be displayed as soon as
the Employer field has lost the focus/ been up dated.

Any help would be very much appreciated.

Thanks Bob
 
The code is currently embedded in the Form_Current event. You want it to
run after you select an Employee. You might need to put it in a different
event...
 
A couple of things:

1. Jeff is right - you are never going to get the results you want if
you put the code in the form's OnCurrent event. When the current record
is selected, it'll check the value and execute the appropriate code.
That's the way things will stay until you switch to the next record,
when the event runs again. That's also why, when you switch out and then
back, it works right. So you might want to keep a copy of the code where
you have it, but also add it to an event on the Employee field. You
should try AfterUpdate or perhaps OnExit.

2. You might want to consider the possibility that your txtInFo values
aren't truly null. If, for example, they have a "" string value, they're
not Null, per se. You might add Or txtInFo = "" to your If statement?

Hope this helps!

grep
 
Back
Top