Jim Lawrence
accessd at shaw.ca
Mon May 24 20:41:12 CDT 2010
Hi Bill: There are a few comments about the code I will make. 1. Why are you setting all the objects to 'nothing'. If these are variables especially and if you didn't set them to Public, exiting from a form will close them automatically. 2. Avoid such names as Prp, lbl, Ctl, Frm as the system can get confused with them; try PrpValues, lblNameGeorge, CtlNamePopdown, FrmGeorge and considering non descriptive naming would confuse you when going through the code a year later... Recordsets are one of the exception when closing and setting to nothing. 3. If you are closing the current form you might check to see if the form you are closing is the form you want to close: strFrmName = Me.Form.Name DoCmd.Close acForm, strFrmName, acSaveYes 4. If that does not work check to see if all your references are correct... through one of your Modules. If you do not already have one, create a dummy one and go into design mode then you will have access to the above mentioned feature. 5. While in a Module the run 'Debug' and 'save'. Debug will catch a lot of programmer errors. 6. If that does not work make a new form and drag and drop the code and fields into the new form... sometimes a form just gets corrupted and can not be fixed. HTH Jim -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Bill Benson (vbacreations) Sent: Monday, May 24, 2010 2:06 PM To: 'Access Developers discussion and problem solving' Subject: [AccessD] Cannot close a form with Docmd.Close I am trying to close a form. A lot was done on this form before I get to the line to close it, but I am being told "The close action was canceled". I later added a whole bunch of cleanup lines, and it went through everything and DID close immediately after I added these lines. Then I thought, well why not test them one by one to see which helped. So I turned them all off one at a time and found none helped. Thinking I was going insane, I added all the lines back and the form wouldn't close. Can someone tell me what might be going on without looking at all the code? Nothing I know of could be clinging to the form. Debug.Print Forms.count = 1. The form was opened with this line: DoCmd.OpenForm MyTemplate, acDesign, , , acFormEdit, acHidden TIA! Set T = Nothing Set D = Nothing Set R = Nothing Set Prp = Nothing Set Lbl = Nothing Set LastControl = Nothing Set Txt = Nothing Set Ctl = Nothing Set Frm = Nothing Set F = Nothing ReDim VarOriginalControls(0) ReDim ArSkip(0) DoCmd.Close acForm, FrmName, acSaveYes -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com