Dan Waters
dwaters at usinternet.com
Fri Jan 25 19:41:24 CST 2008
I get this in my error logs once in a while too. Nice sleuthing John! Each time I get this from now on I can add this as a potential fix. Thanks! -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby Sent: Friday, January 25, 2008 2:59 AM To: 'Access Developers discussion and problem solving' Subject: [AccessD] The expression you entered refers to an object that is closed or doesnt exist. How many of you have come across that error? I have a system where the user selects some criteria, then a form is opened using that criteria. There is a command button that is the "default" button (clicked if the user hits enter) which loads the form, so the user can either click the button with the mouse or just hit enter. I was getting "The expression you entered refers to an object that is closed or doesn't exist." very occasionally as the form opened. I finally discovered that if I tapped the enter key several times as the form loaded, Access sensed TWO key clicks and thus tried to open the form a second time. I got rid of the error with the following code: Private Sub but_wrksht_Click() On Error GoTo Err_but_wrksht_Click Static blnOpening As Boolean If blnOpening Then Exit Sub blnOpening = True OpenClaimFrm blnOpening = False Exit_but_wrksht_Click: Exit Sub end sub As you can see, I create a static variable, set it to True as I pass through the first time and clear it again as the OpenClaimForm() finished. If the click event is sensed a second time while the OpenClaimForm() is still processing, the blnOpening is still true and the sub is exited. What a PITA Access is sometimes. John W. Colby Colby Consulting www.ColbyConsulting.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com