Ms Access Error 2166
FORUMSFOR COMPUTER PROFESSIONALS Log In Come Join Us! Are you aComputer / IT professional?Join Tek-Tips Forums! Talk With Other Members Be Notified Of ResponsesTo Your Posts Keyword Search One-Click Access To YourFavorite Forums Automated SignaturesOn Your Posts Best Of All, It's Free! Join Us! *Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail. Posting Guidelines Promoting, selling, recruiting, coursework and thesis posting is forbidden.Tek-Tips Posting Policies Jobs Jobs from Indeed What: Where: jobs by Link To This Forum! Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.Just copy and paste the BBCode HTML Markdown MediaWiki reStructuredText code below into your site. Microsoft: Access Forms Forum at Tek-Tips HomeForumsProgrammersDBMS PackagesMicrosoft: Access Forms Forum runtime error 2166 thread702-999405 Forum Search FAQs Links MVPs runtime error 2166 runtime error 2166 bw2601 (TechnicalUser) (OP) 4 Feb 05 12:17 hiI am trying to lock a field inmy table so after a user enters data it will lock.This is my code:private sub fieldname_change()if not isnull(me.fieldname) thenme.fieldname.locked = trueelseme.fieldname.locked = falseend iffend subwhen i try to test it i get a runtime error 2166 "cannot lock a control while it has unsaved changes."can any one help me figure out why i am getting this error.thanks RE: runtime error 2166 TheAceMan1 (Programmer) 4 Feb 05 13:15 CODEprivate sub fieldname_change()Docmd.RunCommand acCmdSaveRecordif not isnull(me.fieldname) thenme.fieldname.locked = trueelseme.fieldname.locked = falseend iffend subAnd if the user makes a typo? See Ya! ...... RE: runtime error 2166 bw2601 (TechnicalUser) (OP) 4 Feb 05 14:54 Sry that did not work.I still get the same error, and depending on where i place the code i also get this error:runtime 3101, Microsoft jet database engine cannot find matching field(s) "fieldname"any suggestions??please? RE: runtime error 2166 TheAceMan1 (Programmer) 4 Feb 05 15:15 bw2601 . . . . .Sorry . . . I didn't pay attention to your use of the Change event.Hmmmmm . . . what is your definition of locked as far as your trying to use it?Is this on a network? See Ya! ...... RE: runtime error 2166 bw2601 (TechnicalUser) (OP) 4 Feb 05 15:2
for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Ask a Question Ask for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Expand Search Submit Close Search Login Join Today Products BackProducts Gigs Live Careers Vendor Services Groups Website Testing Store Headlines Experts Exchange > Questions > getting this runtime error 2166? Want to Advertise Here? Solved getting this runtime error 2166? Posted on 2006-05-31 MS Access 2 Verified Solutions 12 Comments 1,055 Views Last Modified: 2012-08-22 I am trying to lock a http://www.tek-tips.com/viewthread.cfm?qid=999405 control (textbox) in a sub on a change event on another textbox. I am getting this error: run-time error 2166 You can't lock a control while it has unsaved changes Now I have not made any changes to this control that I'm trying to lock; when I test it it shows a value of Null. 0 Question by:szx248 Facebook Twitter LinkedIn Google LVL 16 Best Solution byRick_Rickards https://www.experts-exchange.com/questions/21870623/getting-this-runtime-error-2166.html The Change Event... 1) Fires every time anything in the control changes (when changes are being executed from within the control itself) 2) Avails the contents of the control only via the .Text Go to Solution 10 Comments LVL 13 Overall: Level 13 MS Access 12 Message Expert Comment by:John Mc Hale2006-06-01 Can you be more specific and post some code? 0 Message Author Comment by:szx2482006-06-01 in an On Change (same with After Update) when I run this If (Val(Nz(Me.CountMale.Text, 0)) + Val(Nz(Me.CountFemale, 0))) > 1 Then Me.Age.Value = "" Me.Age.Enabled = False Me.Age.Locked = True << -- error on this line Me.Age.BackColor = 14215660 Else Me.Age.Enabled = True Me.Age.Locked = False Me.Age.BackColor = vbWhite End If 0 LVL 13 Overall: Level 13 MS Access 12 Message Expert Comment by:John Mc Hale2006-06-01 try: If (Val(Nz(Me.CountMale.Text, 0)) + Val(Nz(Me.CountFemale, 0))) > 1 Then Me.Age.Value = Null Call Age_AfterUpdate Me.Age.Enabled = False Me.Age.Locked = True << -- error on this line Me.Age.BackColor = 14215660 Else Me.Age.Enable
be down. Please try the request again. Your cache administrator is webmaster. Generated Wed, 19 Oct 2016 08:10:10 GMT by s_ac4 (squid/3.5.20)
Social Groups Pictures & Albums Members List Calendar Search Forums Show Threads Show Posts Tag Search Advanced Search Find All Thanked Posts Go to Page... Thread Tools Rate Thread Display Modes 06-04-2002, 11:19 AM #1 dan-cat Newly Registered User Join Date: Jun 2002 Location: KY,USA Posts: 3,425 Thanks: 0 Thanked 18 Times in 18 Posts Setting locked property I am having trouble setting the lock property of a field to true. I have a combo field called "Type" in the Main Order form. I want to lock this field whenever there is a record within the Sub Order form. Here is what I have written so far - with ProductCode being the field within the subform. Private Sub ProductCode_AfterUpdate() [Forms]![frmOrders]![Type].Locked = True End Sub However I get the following error: "Run-time error - '2166' you can't lock a control whilst it has unsaved changes" __________________ Pinky has always been there for me dan-cat View Public Profile Find More Posts by dan-cat 06-27-2002, 02:06 PM #2 mbentley Registered User Join Date: Jan 2002 Location: Edmonton, Alberta, Canada Posts: 138 Thanks: 0 Thanked 0 Times in 0 Posts It's probably because the "Type" field is dirty, meaning that the information in it has changed. You probably need to save the changes to the record before you lock the field. Not sure if you necessarily want to do that, but it should work. __________________ Mike Never underestimate the user's ability to do something completely unexpected. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. mbentley View Public Profile Visit mbentley's homepage! Find More Posts by mbentley « Previous Thread | Next Thread » Thread Tools Show Printable Version Email this Page Display Modes Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Rate This Thread Excellent Good Average Bad Terrible Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Access World Access World News Site Suggestions Introduce Yourself The Watercooler Microsoft Access Discussion General Tables Queries Forms Reports Macros Modules & VBA Theory and practice of database design Access Web Microsoft Access Reference Access FAQs Code Repository Sample Databases Microsoft Access Tutorials Microsoft Access User Groups Apps and Windows SQL Server Crystal Reports Visual Basic VB.NET Word Excel Web Design and Development