Ghosting Fields in a form

S

Surrealdogma

I have a form / subform that I would like to either "ghost out" or somehow
render unusable for a record if a field in that record has a date in it, and
render the fields usable again if that field doesn't have a date. All I have
come up with so far is a macro using "set Value" and setting the Enabled
value to no, but that blanks my fields out for all the records, not just the
one.
Thanks in advance for your assistance.
 
A

Arvin Meyer [MVP]

I'm going to guess that this is happening in a continuous form or in a
form's datasheet view. That is normal behavior. What you can do is to use
the form's Current event to simply lock the control. In a continuous form,
it will lock them all, but that's OK if you are using the form's Current
event because it fires as every record gets focus. Something like this
(aircode):

Sub Form_Current()
If Len(Me.txtDateField & vbNullString) > 0 Then
Me.txtDateField.Locked = True
Else
Me.txtDateField.Locked = False
End If
End Sub
 
S

Surrealdogma

This is great! Thank you!

Arvin Meyer said:
I'm going to guess that this is happening in a continuous form or in a
form's datasheet view. That is normal behavior. What you can do is to use
the form's Current event to simply lock the control. In a continuous form,
it will lock them all, but that's OK if you are using the form's Current
event because it fires as every record gets focus. Something like this
(aircode):

Sub Form_Current()
If Len(Me.txtDateField & vbNullString) > 0 Then
Me.txtDateField.Locked = True
Else
Me.txtDateField.Locked = False
End If
End Sub
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 
Top