Form not closing for event "leaving field"

J

jokobe

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
 
M

Maurice

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
 
J

jokobe

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
 
K

kubios

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.
 
K

kubios

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?
 
J

John W. Vinson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top