[AccessD] Locking a textbox based on other form controls

Gustav Brock Gustav at cactus.dk
Thu Aug 17 02:04:06 CDT 2006


Hi Chris

This should be possible. You can even change the value of a locked textbox via code.
Something else must be going on. Are you sure the form - not only the textboxes - is unbound?

/gustav


>>> cjeris at fas.harvard.edu 16-08-2006 21:52:13 >>>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This is probably fairly simple but I haven't gotten far with the help and
Google.

Access XP.  I have an unbound form containing several textboxes and some
action buttons.  Based on which action button the user presses, I want some
of the textboxes to become non-writable and others to remain writable.

When a record is loaded into the form, the textboxes are initialized using
statements of the form

acForm![faaCustomerID].Value = "1264"

and each such textbox has its Locked property set to False.

Later, in a function called from one of the command buttons' _Click()
handlers, I attempt to do

acForm![faaCustomerID].Locked = True

and receive

Run-time error 2166: You can't lock a control that has unsaved changes.

Now from the help for the properties TextBox.Text, TextBox.Value, it seems
that "unsaved changes" means that .Text <> .Value .  That isn't true here,
as far as I can tell, since nothing has acted to edit the control since I
set its .Value property.

What don't I understand here?  How can I convince Access to let me lock
these controls?

thanks, Chris Jeris





More information about the AccessD mailing list