Ghosting Fields in a form

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

Guest

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.
 
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
 
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
 

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

Back
Top