Form not closing for event "leaving field"

  • Follow


Within a form the input-data (number) is checked wether it is already in the 
database. If it is already in the database, I want to open a new form and 
close the first form.
But, when trying this, I always get the errorr "can't close form while event 
still running" (sorry, it is a translation from german).
Any helpful hints how to solve the problem

Thanks in advance

Jokobe
0
Reply Utf 3/6/2008 1:04:02 PM

jokobe,

Does that mean that when the input data is already in the db the record is 
not saved or shouldn't be saved? My guess is that your form state is still 
'dirty' and therfore doesn't want to open the form.

Try adding me.undo (if the record shouldn't be saved) and me.dirty =false to 
interrupt the state of the form.

place these two options in the sub where you are doing the testing for the 
existing of the inputnumber.

hth
-- 
Maurice Ausum


"jokobe" wrote:

> Within a form the input-data (number) is checked wether it is already in the 
> database. If it is already in the database, I want to open a new form and 
> close the first form.
> But, when trying this, I always get the errorr "can't close form while event 
> still running" (sorry, it is a translation from german).
> Any helpful hints how to solve the problem
> 
> Thanks in advance
> 
> Jokobe
0
Reply Utf 3/6/2008 9:38:05 PM


Hi Maurice,

thanks for your answer, but it is not working. The first form "CheckInput" 
is open. After entering the data in a field it is checked when leaving 
whether the number is already in the data base. If not inserting more data in 
the next field leads to a button to close the CheckInput form and open a new 
form. That is working fine, but, when the check for the number is  done on 
leaving the field, it is not working. This seems to be because the event 
"when leaving" isn't finished. I'm using the  Docmd.close "checkInput" within 
the event "when leaving" and the answer is "this action can't be performed 
because the form event is not finished". The form event seems to be the "when 
leaving".

jokobe

"Maurice" wrote:

> jokobe,
> 
> Does that mean that when the input data is already in the db the record is 
> not saved or shouldn't be saved? My guess is that your form state is still 
> 'dirty' and therfore doesn't want to open the form.
> 
> Try adding me.undo (if the record shouldn't be saved) and me.dirty =false to 
> interrupt the state of the form.
> 
> place these two options in the sub where you are doing the testing for the 
> existing of the inputnumber.
> 
> hth
> -- 
> Maurice Ausum
> 
> 
> "jokobe" wrote:
> 
> > Within a form the input-data (number) is checked wether it is already in the 
> > database. If it is already in the database, I want to open a new form and 
> > close the first form.
> > But, when trying this, I always get the errorr "can't close form while event 
> > still running" (sorry, it is a translation from german).
> > Any helpful hints how to solve the problem
> > 
> > Thanks in advance
> > 
> > Jokobe
0
Reply Utf 3/7/2008 1:54:04 PM

Since I can't seem to start a new thread and I believe my problem is the same 
as jokobe's, I'll post here and hope someone can solve it.

I created a PasswordEntry form. The user enters the password in a box and 
hits enter and if the password is correct, another form is opened for the 
user. I then want the password form to close.
I created an exit event procedure (on the password box in the password form) 
as follows:

Private Sub PasswordBox_Exit(Cancel As Integer)
Dim vsPswd As String
Me.Passwordwrongnotify = "" 
Const conGoodPswd As String = "rad05"
    If Me.PasswordBox = conGoodPswd Then
        Me.PasswordWrongNotify = ""
        Me.PasswordBox = ""
        DoCmd.OpenForm "frmMaintenanceMenu"
        DoCmd.Close acForm, "frmpasswordentry"

    Else
        Me.PasswordWrongNotify = "#   #   #   #   INCORRECT PASSWORD   #   # 
  #   #"
        Me.PasswordBox = ""
    End If
End Sub

When you enter the correct password, I always get the follwowing error:

Run-time error '2585':
This action can't be carried out while processing a form or report event.

So....  I took the    DoCmd.Close acForm, "frmpasswordentry"   statement out 
of the exit event procedure and put it in the On Open event procedure of the 
new form (frmMaintenanceMenu) that was being openned by the password form and 
I get the exact same error message.

I have been working on this problem on and off for hours. Can anyone help.

-- 
Thanks,
Kubios


"jokobe" wrote:

> Within a form the input-data (number) is checked wether it is already in the 
> database. If it is already in the database, I want to open a new form and 
> close the first form.
> But, when trying this, I always get the errorr "can't close form while event 
> still running" (sorry, it is a translation from german).
> Any helpful hints how to solve the problem
> 
> Thanks in advance
> 
> Jokobe
0
Reply Utf 3/8/2008 7:45:00 PM

On Sat, 8 Mar 2008 11:45:00 -0800, kubios <kubios@discussions.microsoft.com>
wrote:

>I created an exit event procedure 

Wrong event. Use AfterUpdate instead.
-- 

             John W. Vinson [MVP]
0
Reply John 3/8/2008 8:36:32 PM

John,

It worked perfectly. Thanks so much for your help.

I looked up the differences between the two events and it is still unclear 
to me why after update works and not on exit.

 Can you explain?

-- 
Thanks,
Kubios


"John W. Vinson" wrote:

> On Sat, 8 Mar 2008 11:45:00 -0800, kubios <kubios@discussions.microsoft.com>
> wrote:
> 
> >I created an exit event procedure 
> 
> Wrong event. Use AfterUpdate instead.
> -- 
> 
>              John W. Vinson [MVP]
> 
0
Reply Utf 3/8/2008 8:58:03 PM

On Sat, 8 Mar 2008 12:58:03 -0800, kubios <kubios@discussions.microsoft.com>
wrote:

>John,
>
>It worked perfectly. Thanks so much for your help.
>
>I looked up the differences between the two events and it is still unclear 
>to me why after update works and not on exit.
>
> Can you explain?

After update fires when a *selection* has been made in the combo box.

Exit fires whenever the user leaves the combo box, whether they've selected
anything or not - just tabbing or clicking around the form will cause it to
fire.
-- 

             John W. Vinson [MVP]
0
Reply John 3/8/2008 9:50:24 PM

Thanks again for all your help.
-- 
Thanks,
Kubios


"John W. Vinson" wrote:

> On Sat, 8 Mar 2008 12:58:03 -0800, kubios <kubios@discussions.microsoft.com>
> wrote:
> 
> >John,
> >
> >It worked perfectly. Thanks so much for your help.
> >
> >I looked up the differences between the two events and it is still unclear 
> >to me why after update works and not on exit.
> >
> > Can you explain?
> 
> After update fires when a *selection* has been made in the combo box.
> 
> Exit fires whenever the user leaves the combo box, whether they've selected
> anything or not - just tabbing or clicking around the form will cause it to
> fire.
> -- 
> 
>              John W. Vinson [MVP]
> 
0
Reply Utf 3/8/2008 11:00:01 PM

7 Replies
219 Views

(page loaded in 0.143 seconds)

Similiar Articles:











7/29/2012 12:08:02 AM


Reply: