A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Multiple Instances of Form Created By Form Open



 
 
Thread Tools Display Modes
  #1  
Old February 17th, 2006, 04:43 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Multiple Instances of Form Created By Form Open

I'm using Access 2002 on Windows 2000. I have a search form where the
user selects a row in the subform data sheet and then clicks an open
button to bring up another form with the data related to the row they
selected. The open button runs some simple code that does a form open
based on the primary key field in the subform. In testing, our QA
inadvertently clicked multiple times on the open button and ended
creating 10 plus instances of the form (I didn't think this was
possible in Access) and if you try to click on one of the instances
Access crashes.

I tried disabling the open button as the first action in the on_click
event and I also tried checking to see if the form was already open
before executing the Docmd.OpenForm, but that didn't help. This
strange behavior only happens about every 20th time the QA tries
multiple clicks. Is this some strange Access bug? Any ideas or
suggestions would be greatly appreciated.

Thanks, David.

  #2  
Old February 17th, 2006, 06:40 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Multiple Instances of Form Created By Form Open

To disable the button, you must first move the focus to another control with
a SetFocus statement. Checking to see if the form is open before running the
code should work unless the user is clicking so quickly that the form isn't
detected as being open yet. If that's the case, after the OpenForm command,
try issuing a SetFocus command to the form you just opened followed by a
DoEvents statement to allow the system to catch up. Another option would be
to set a "flag" variable when you open the form and check the value of the
flag before you allow the form to open. This value will take effect
immediately and so should be available the next time you run through the
code. You will also need to clear the value of this variable when you close
the form. This could be done in the pop-up's Close event. Since the variable
will be accessed from more than one form, it should be a Global variable and
declared (Dim'ed) in a standard module.

--
Wayne Morgan
MS Access MVP


"David S" wrote in message
oups.com...
I'm using Access 2002 on Windows 2000. I have a search form where the
user selects a row in the subform data sheet and then clicks an open
button to bring up another form with the data related to the row they
selected. The open button runs some simple code that does a form open
based on the primary key field in the subform. In testing, our QA
inadvertently clicked multiple times on the open button and ended
creating 10 plus instances of the form (I didn't think this was
possible in Access) and if you try to click on one of the instances
Access crashes.

I tried disabling the open button as the first action in the on_click
event and I also tried checking to see if the form was already open
before executing the Docmd.OpenForm, but that didn't help. This
strange behavior only happens about every 20th time the QA tries
multiple clicks. Is this some strange Access bug? Any ideas or
suggestions would be greatly appreciated.

Thanks, David.



  #3  
Old February 17th, 2006, 07:00 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Multiple Instances of Form Created By Form Open

"David S" wrote in message
oups.com
I'm using Access 2002 on Windows 2000. I have a search form where the
user selects a row in the subform data sheet and then clicks an open
button to bring up another form with the data related to the row they
selected. The open button runs some simple code that does a form open
based on the primary key field in the subform. In testing, our QA
inadvertently clicked multiple times on the open button and ended
creating 10 plus instances of the form (I didn't think this was
possible in Access) and if you try to click on one of the instances
Access crashes.


That shouldn't be possible using "simple code", though it is possible
using code that I would consider "advanced". What is the code behind
the button?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


  #4  
Old February 23rd, 2006, 07:47 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Multiple Instances of Form Created By Form Open

The code uses ADO to load some local tables and then does a
docmd.openform and a docmd.close to close the search form. The form
being opened resets its recordset based on the ID that was selected on
the search form. The one unique thing about the form is that it uses
the spreadsheet control.

It seems that this issue is specific to Office XP Service Pack 2. We
can't recreate it on my machine that's running SP1 and when we upgraded
the QA's machine to SP3 she could no longer seem to create the issue
(she's going to do more testing tomorrow).

I've tried some of Wayne's suggestions and the error still occurred. I
also tried putting a log function in the routines being executed and my
code only runs once. I also was able to get back to Access when the
extra forms were displayed and Access only thought there was one form
open. If you try and click on one of the extra forms Access crashes.
When Access displayed its closing message we said "send report" and
followed the prompts -- the messages seemed to indicate that this was a
known problem and that we should install SP3.

-- David.

  #5  
Old February 23rd, 2006, 03:03 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Multiple Instances of Form Created By Form Open

David,

Thanks for the follow up. Yes, if SP3 fixes it, then it sounds as if you've
found your solution. As Dirk had mentioned, "it shouldn't do that" without
some special coding on your part.

--
Wayne Morgan
MS Access MVP


"David S" wrote in message
oups.com...
The code uses ADO to load some local tables and then does a
docmd.openform and a docmd.close to close the search form. The form
being opened resets its recordset based on the ID that was selected on
the search form. The one unique thing about the form is that it uses
the spreadsheet control.

It seems that this issue is specific to Office XP Service Pack 2. We
can't recreate it on my machine that's running SP1 and when we upgraded
the QA's machine to SP3 she could no longer seem to create the issue
(she's going to do more testing tomorrow).

I've tried some of Wayne's suggestions and the error still occurred. I
also tried putting a log function in the routines being executed and my
code only runs once. I also was able to get back to Access when the
extra forms were displayed and Access only thought there was one form
open. If you try and click on one of the extra forms Access crashes.
When Access displayed its closing message we said "send report" and
followed the prompts -- the messages seemed to indicate that this was a
known problem and that we should install SP3.

-- David.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Form won't open report from preview button jwr Using Forms 5 October 29th, 2005 04:53 PM
Multiple Instances of a form - Form name Danny Using Forms 1 April 21st, 2005 02:44 PM
multiple instances of a form x 2 Miranda Using Forms 5 September 4th, 2004 01:11 AM
Strange stLinkCriteria behaviour on command button Anthony Dowd Using Forms 3 August 21st, 2004 03:01 AM
auto entry into second table after update Tony New Users 13 July 9th, 2004 10:42 PM


All times are GMT +1. The time now is 06:19 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.