Enable control/field if in Add New Record page/form

S

Steve Stad

I have a field that I disable in the Edit mode of a form but I would like to
Enable the same field/control when the same form is in the 'Add new Record'
mode. Can you tell me the code and event to use.
 
J

Jack Leach

In the form's OnCurrent event (every time it moves to a new record), include
this code:

If Me.NewRecord Then
Me.Controlname.Enabled = True
Else
Me.Controlname.Enabled = False
End If


this could be simplified to one line:

Me.Controlname.Enabled = Me.NewRecord


Or, if you are talking about the AllowAdditions and AllowEdits properties,
you can use the Open even of the form to set it (though there's no particular
advantage that I can think of to do it this way over using the Current event)

Me.Controlname = Me.AllowAdditions


hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 

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

Top