Gustav Brock
Gustav at cactus.dk
Thu Aug 17 11:11:25 CDT 2006
Hi Chris Oh, this is completely different from what you originally told you were doing - clicking a button to set the locking ... Try to move your code from the Change to the AfterUpdate event of the textbox. /gustav >>> cjeris at fas.harvard.edu 17-08-2006 17:40:19 >>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Charlotte Foust wrote: > Only if you don't set the form's recordset or RecordSource property from > code. And Text is a read only property of Access textboxes. It can > only be read when the control has the focus. Otherwise, you have to use > the Value property. What you're describing sounds a lot like what > happens when a bound textbox has a change made in code to the underlying > recordset and the user then tries to change the value from the UI and > save the record. The two changes collide and Access complains mightily. Okay, here's a minimal example that illustrates the problem. Create a blank form Form1 in Access XP. Add two controls to it: text-boxes Text0 and Text2. The entire content of the VB module Form_Form1 is as follows. Option Compare Database Option Explicit ' The function of Text2 is that when it is changed, Text0 is locked: Private Sub Text2_Change() Me![Text0].Locked = True End Sub Save this form and module. Open the form in Form View. Then click in Text2 and try to change the populated value. Run-time error '2166': You can't lock a control while it has unsaved changes. What unsaved changes? No value has ever been typed or set into Text0 for the entire lifetime of this database file! What am I missing here? thanks, Chris Jeris