Form Field Available in Add Mode Only

  • Thread starter Thread starter jason.lindsay
  • Start date Start date
J

jason.lindsay

I have a field in a subform I'm designing that I would
only like to have available to the user when adding a new
record. The value is part of a concatenated key I'm using
in that table, and I want to force users to delete/re-add
the record if they enter the wrong key value.

How do I make a field enabled only when adding a new
record? I've tried re-setting the focus in conjunction
with toggling the enabled and locked property for the
field, with less than spectacular results. Any ideas?
 
Jason,

In the current event of the subform place this line:

[myControl].Enabled = Me.NewRecord

where myControl is the name of a textbox or other control.

God Bless,

Mark A. Sam
 
Mark,
Thanks for the tip. Unfortunately, the control I want to
enable for only add mode is the first control on the line,
and I get an error stating "can't disable control while it
has the focus"

I think I might have a work-around... in the OnChange
event, check for me.newrecord, and if it's false, set the
control back to the old value and set the focus to the
next control. Not the greatest solution, but it works.

Thanks again,
Jason
 
Jason,

When I need to move the focus off of a control to Disable it, I put a
transparent button on the form and give it the focus.
 
Back
Top