Check for Open Form

  • Thread starter Thread starter DavidW
  • Start date Start date
D

DavidW

Is there a way to check to see if a specific form is open from a different
form through code and if there is a specific form other than the current
form open ,be able to close that form
What the deal is
When a certain condition developes during data entry(as in a duplicated
entry), I want to be able to give the user a chance to delete the existing
entry if needed(sometimes I have to have a duplicated entry), the problem I
am getting is that the code that checks for that is in the on current event,
it looks at 2 different subforms linked by unit and if both units match ,my
codes pops a popup and ask them what they want to do. Now if they select yes
to delete the existing entry, I am opening a form that show the existing
enteries, and I am also trying to close the form that triggered the event,
but I can't because it says that it cannot carry out the event while
processing a form. Is there a way to do this, or am I barking up the wrong
tree?
Thanks David
 
im not 100% sure what you are trying to do, but ill help
if i can

to close a form, do you use

DoCmd.Close acForm, Form.Name

also, to find if a certain form is currently open you can
do this:

Dim f as Form
For each f in Forms
If f.Name = "MyForm" then
'form is open
end if
Next f

if you are saying that form1 cant be closed from form2
because form1 opened form2 then try closing form1 from
within form1, right after the code that opened form2

if somehow you are opening the form asychronously, im not
sure what you would do because im didn't think you could
do that

hope that helps. if im not anywhere's close try explaining
your example abit more clearly
 
Yes I do specify which form to close with
docmd.close acform,("myform")
form 1 does open form 2, and I am trying too close form1 within form1, but I
get the error that it cannot be closed while processing the form. Is there a
way to kill the form
The code that runs this event is on the on current so that it can check each
record as the form goes to the next
Thanks
David
 
Back
Top