on exit event

  • Thread starter Thread starter help
  • Start date Start date
H

help

I have added code to verify a user is entering in
information for an Applicant form to correspond with sub-
form. However this msgbox continously pops up and won't
let me click the close button or find in case the user
did not want to add a new applicant. The Msgbox is in the
on exit of the control of the Applicant's last name.

ex.
If IsNull([Applicant1 Last Name]) Then
MsgBox "You must enter the Applicant's Last Name"
DoCmd.CancelEvent
 
Is there a field named Applicatnt1 Last Name in the form's recordsource? And
is the control that is named Applicant1 Last Name bound to this field? If
yes, ACCESS is assuming that you mean the field and not the control in your
code. Change the name of the control to txtApplicant1 and use this name in
the code.
 
Additionally, use the control's OnBeforeUpdate event for your code, not the
OnExit event.
 
Use the BeforeUpdate event of your form instead.

If IsNull([Applicant1 Last Name]) Then
MsgBox "You must enter the Applicant's Last Name"
Cancel = True
Me.[Applicant1 Last Name].SetFocus
End If
 
In the BeforeUpdate event of the form I have code to ask
the user if they would like to save the current record,
before adding date to the subform.
If MsgBox("Save Changes to Applicant Record?", vbYesNo) =
vbNo Then
'Cancel = True
Me.Undo
End If
I added this because when I clicked on a field in the
subform before entering any data in the mainform I
received an error - to do with the primary key on the
main form not having any data - it is an autonumber. Is
there any way other way to check if data was not entered
in the Applicant1 text box. If I did put the code in the
OnBeforeUpdate it stopped the OnBeforeUpdate for the form
to stop working...thanks again
-----Original Message-----
Additionally, use the control's OnBeforeUpdate event for your code, not the
OnExit event.

--

Ken Snell
<MS ACCESS MVP>

I have added code to verify a user is entering in
information for an Applicant form to correspond with sub-
form. However this msgbox continously pops up and won't
let me click the close button or find in case the user
did not want to add a new applicant. The Msgbox is in the
on exit of the control of the Applicant's last name.

ex.
If IsNull([Applicant1 Last Name]) Then
MsgBox "You must enter the Applicant's Last Name"
DoCmd.CancelEvent


.
 
I am not understanding. You don't want to force an entry into the textbox
before the user can click into the subform? Or you do want to force the
entry? I do not unsderstand why the control's BeforeUpdate event "stopping"
the form's BeforeUpdate event is bad?

Perhaps you can explain in more detail what you want the form to do and what
you want the user to do.

--

Ken Snell
<MS ACCESS MVP>

In the BeforeUpdate event of the form I have code to ask
the user if they would like to save the current record,
before adding date to the subform.
If MsgBox("Save Changes to Applicant Record?", vbYesNo) =
vbNo Then
'Cancel = True
Me.Undo
End If
I added this because when I clicked on a field in the
subform before entering any data in the mainform I
received an error - to do with the primary key on the
main form not having any data - it is an autonumber. Is
there any way other way to check if data was not entered
in the Applicant1 text box. If I did put the code in the
OnBeforeUpdate it stopped the OnBeforeUpdate for the form
to stop working...thanks again
-----Original Message-----
Additionally, use the control's OnBeforeUpdate event for your code, not the
OnExit event.

--

Ken Snell
<MS ACCESS MVP>

I have added code to verify a user is entering in
information for an Applicant form to correspond with sub-
form. However this msgbox continously pops up and won't
let me click the close button or find in case the user
did not want to add a new applicant. The Msgbox is in the
on exit of the control of the Applicant's last name.

ex.
If IsNull([Applicant1 Last Name]) Then
MsgBox "You must enter the Applicant's Last Name"
DoCmd.CancelEvent


.
 
I added the msgbox in the onexit for the control of the
txtApplicant1 because if the userclicks on the subform
and enters data I get an error message that the main form
required data in the autonumber (the autonumber does not
increase until data has been entered in the main form).
Basically, this works but when I try to click on Find or
Close I without any data entered in the txtApplicant1 I
recieve the message box to enter data. Hope this makes
more sense, and thanks for your help.
-----Original Message-----
I am not understanding. You don't want to force an entry into the textbox
before the user can click into the subform? Or you do want to force the
entry? I do not unsderstand why the control's BeforeUpdate event "stopping"
the form's BeforeUpdate event is bad?

Perhaps you can explain in more detail what you want the form to do and what
you want the user to do.

--

Ken Snell
<MS ACCESS MVP>

In the BeforeUpdate event of the form I have code to ask
the user if they would like to save the current record,
before adding date to the subform.
If MsgBox("Save Changes to Applicant Record?", vbYesNo) =
vbNo Then
'Cancel = True
Me.Undo
End If
I added this because when I clicked on a field in the
subform before entering any data in the mainform I
received an error - to do with the primary key on the
main form not having any data - it is an autonumber. Is
there any way other way to check if data was not entered
in the Applicant1 text box. If I did put the code in the
OnBeforeUpdate it stopped the OnBeforeUpdate for the form
to stop working...thanks again
-----Original Message-----
Additionally, use the control's OnBeforeUpdate event
for
your code, not the
OnExit event.

--

Ken Snell
<MS ACCESS MVP>

I have added code to verify a user is entering in
information for an Applicant form to correspond with sub-
form. However this msgbox continously pops up and won't
let me click the close button or find in case the user
did not want to add a new applicant. The Msgbox is
in
the
on exit of the control of the Applicant's last name.

ex.
If IsNull([Applicant1 Last Name]) Then
MsgBox "You must enter the Applicant's Last Name"
DoCmd.CancelEvent



.


.
 
What I suggest is that you put code in the subform's OnEnter event that
tests for the presence or absence of info in that textbox. If there is info,
then the code ends. If there is not info, then the code displays the error
message, sets the focus back to that control, and then ends.

--

Ken Snell
<MS ACCESS MVP>

I added the msgbox in the onexit for the control of the
txtApplicant1 because if the userclicks on the subform
and enters data I get an error message that the main form
required data in the autonumber (the autonumber does not
increase until data has been entered in the main form).
Basically, this works but when I try to click on Find or
Close I without any data entered in the txtApplicant1 I
recieve the message box to enter data. Hope this makes
more sense, and thanks for your help.
-----Original Message-----
I am not understanding. You don't want to force an entry into the textbox
before the user can click into the subform? Or you do want to force the
entry? I do not unsderstand why the control's BeforeUpdate event "stopping"
the form's BeforeUpdate event is bad?

Perhaps you can explain in more detail what you want the form to do and what
you want the user to do.

--

Ken Snell
<MS ACCESS MVP>

In the BeforeUpdate event of the form I have code to ask
the user if they would like to save the current record,
before adding date to the subform.
If MsgBox("Save Changes to Applicant Record?", vbYesNo) =
vbNo Then
'Cancel = True
Me.Undo
End If
I added this because when I clicked on a field in the
subform before entering any data in the mainform I
received an error - to do with the primary key on the
main form not having any data - it is an autonumber. Is
there any way other way to check if data was not entered
in the Applicant1 text box. If I did put the code in the
OnBeforeUpdate it stopped the OnBeforeUpdate for the form
to stop working...thanks again
-----Original Message-----
Additionally, use the control's OnBeforeUpdate event for
your code, not the
OnExit event.

--

Ken Snell
<MS ACCESS MVP>

message
I have added code to verify a user is entering in
information for an Applicant form to correspond with
sub-
form. However this msgbox continously pops up and won't
let me click the close button or find in case the user
did not want to add a new applicant. The Msgbox is in
the
on exit of the control of the Applicant's last name.

ex.
If IsNull([Applicant1 Last Name]) Then
MsgBox "You must enter the Applicant's Last Name"
DoCmd.CancelEvent



.


.
 
Therer is no OnEnter event for the subform and the Got
Focus event did not work either.
here is my code:

If IsNull(Me.Applicant!txtApplicant1) Then
MsgBox "You must enter the Applicant's Last Name"
Cancel = True
Me!Applicant!txtApplicant1.SetFocus
End If
-----Original Message-----
What I suggest is that you put code in the subform's OnEnter event that
tests for the presence or absence of info in that textbox. If there is info,
then the code ends. If there is not info, then the code displays the error
message, sets the focus back to that control, and then ends.

--

Ken Snell
<MS ACCESS MVP>

I added the msgbox in the onexit for the control of the
txtApplicant1 because if the userclicks on the subform
and enters data I get an error message that the main form
required data in the autonumber (the autonumber does not
increase until data has been entered in the main form).
Basically, this works but when I try to click on Find or
Close I without any data entered in the txtApplicant1 I
recieve the message box to enter data. Hope this makes
more sense, and thanks for your help.
-----Original Message-----
I am not understanding. You don't want to force an
entry
into the textbox
before the user can click into the subform? Or you do want to force the
entry? I do not unsderstand why the control's BeforeUpdate event "stopping"
the form's BeforeUpdate event is bad?

Perhaps you can explain in more detail what you want
the
form to do and what
you want the user to do.

--

Ken Snell
<MS ACCESS MVP>

In the BeforeUpdate event of the form I have code to ask
the user if they would like to save the current record,
before adding date to the subform.
If MsgBox("Save Changes to Applicant Record?", vbYesNo) =
vbNo Then
'Cancel = True
Me.Undo
End If
I added this because when I clicked on a field in the
subform before entering any data in the mainform I
received an error - to do with the primary key on the
main form not having any data - it is an autonumber. Is
there any way other way to check if data was not entered
in the Applicant1 text box. If I did put the code in the
OnBeforeUpdate it stopped the OnBeforeUpdate for the form
to stop working...thanks again
-----Original Message-----
Additionally, use the control's OnBeforeUpdate
event
for
your code, not the
OnExit event.

--

Ken Snell
<MS ACCESS MVP>

message
I have added code to verify a user is entering in
information for an Applicant form to correspond with
sub-
form. However this msgbox continously pops up and won't
let me click the close button or find in case the user
did not want to add a new applicant. The Msgbox
is
in
the
on exit of the control of the Applicant's last name.

ex.
If IsNull([Applicant1 Last Name]) Then
MsgBox "You must enter the Applicant's Last Name"
DoCmd.CancelEvent



.



.


.
 
There is an On Enter property for the main form's control that holds the
subform. You're looking at the form that is serving as the subform -- and
no, it doesn't contain this property.

--

Ken Snell
<MS ACCESS MVP>

Therer is no OnEnter event for the subform and the Got
Focus event did not work either.
here is my code:

If IsNull(Me.Applicant!txtApplicant1) Then
MsgBox "You must enter the Applicant's Last Name"
Cancel = True
Me!Applicant!txtApplicant1.SetFocus
End If
-----Original Message-----
What I suggest is that you put code in the subform's OnEnter event that
tests for the presence or absence of info in that textbox. If there is info,
then the code ends. If there is not info, then the code displays the error
message, sets the focus back to that control, and then ends.

--

Ken Snell
<MS ACCESS MVP>

I added the msgbox in the onexit for the control of the
txtApplicant1 because if the userclicks on the subform
and enters data I get an error message that the main form
required data in the autonumber (the autonumber does not
increase until data has been entered in the main form).
Basically, this works but when I try to click on Find or
Close I without any data entered in the txtApplicant1 I
recieve the message box to enter data. Hope this makes
more sense, and thanks for your help.
-----Original Message-----
I am not understanding. You don't want to force an entry
into the textbox
before the user can click into the subform? Or you do
want to force the
entry? I do not unsderstand why the control's
BeforeUpdate event "stopping"
the form's BeforeUpdate event is bad?

Perhaps you can explain in more detail what you want the
form to do and what
you want the user to do.

--

Ken Snell
<MS ACCESS MVP>

In the BeforeUpdate event of the form I have code to
ask
the user if they would like to save the current record,
before adding date to the subform.
If MsgBox("Save Changes to Applicant Record?",
vbYesNo) =
vbNo Then
'Cancel = True
Me.Undo
End If
I added this because when I clicked on a field in the
subform before entering any data in the mainform I
received an error - to do with the primary key on the
main form not having any data - it is an autonumber. Is
there any way other way to check if data was not
entered
in the Applicant1 text box. If I did put the code in
the
OnBeforeUpdate it stopped the OnBeforeUpdate for the
form
to stop working...thanks again
-----Original Message-----
Additionally, use the control's OnBeforeUpdate event
for
your code, not the
OnExit event.

--

Ken Snell
<MS ACCESS MVP>

message
I have added code to verify a user is entering in
information for an Applicant form to correspond with
sub-
form. However this msgbox continously pops up and
won't
let me click the close button or find in case the
user
did not want to add a new applicant. The Msgbox is
in
the
on exit of the control of the Applicant's last name.

ex.
If IsNull([Applicant1 Last Name]) Then
MsgBox "You must enter the Applicant's Last Name"
DoCmd.CancelEvent



.



.


.
 
I am confused, I don't see an On Enter property?
-----Original Message-----
There is an On Enter property for the main form's control that holds the
subform. You're looking at the form that is serving as the subform -- and
no, it doesn't contain this property.

--

Ken Snell
<MS ACCESS MVP>

Therer is no OnEnter event for the subform and the Got
Focus event did not work either.
here is my code:

If IsNull(Me.Applicant!txtApplicant1) Then
MsgBox "You must enter the Applicant's Last Name"
Cancel = True
Me!Applicant!txtApplicant1.SetFocus
End If
-----Original Message-----
What I suggest is that you put code in the subform's OnEnter event that
tests for the presence or absence of info in that textbox. If there is info,
then the code ends. If there is not info, then the
code
displays the error
message, sets the focus back to that control, and then ends.

--

Ken Snell
<MS ACCESS MVP>

I added the msgbox in the onexit for the control of the
txtApplicant1 because if the userclicks on the subform
and enters data I get an error message that the main form
required data in the autonumber (the autonumber does not
increase until data has been entered in the main form).
Basically, this works but when I try to click on
Find
or
Close I without any data entered in the txtApplicant1 I
recieve the message box to enter data. Hope this makes
more sense, and thanks for your help.
-----Original Message-----
I am not understanding. You don't want to force an entry
into the textbox
before the user can click into the subform? Or you do
want to force the
entry? I do not unsderstand why the control's
BeforeUpdate event "stopping"
the form's BeforeUpdate event is bad?

Perhaps you can explain in more detail what you
want
the
form to do and what
you want the user to do.

--

Ken Snell
<MS ACCESS MVP>

In the BeforeUpdate event of the form I have code to
ask
the user if they would like to save the current record,
before adding date to the subform.
If MsgBox("Save Changes to Applicant Record?",
vbYesNo) =
vbNo Then
'Cancel = True
Me.Undo
End If
I added this because when I clicked on a field in the
subform before entering any data in the mainform I
received an error - to do with the primary key on the
main form not having any data - it is an autonumber. Is
there any way other way to check if data was not
entered
in the Applicant1 text box. If I did put the code in
the
OnBeforeUpdate it stopped the OnBeforeUpdate for the
form
to stop working...thanks again
-----Original Message-----
Additionally, use the control's OnBeforeUpdate event
for
your code, not the
OnExit event.

--

Ken Snell
<MS ACCESS MVP>

"help" <[email protected]>
wrote
in
message
I have added code to verify a user is entering in
information for an Applicant form to
correspond
with
sub-
form. However this msgbox continously pops up and
won't
let me click the close button or find in case the
user
did not want to add a new applicant. The
Msgbox
is
in
the
on exit of the control of the Applicant's last name.

ex.
If IsNull([Applicant1 Last Name]) Then
MsgBox "You must enter the Applicant's Last Name"
DoCmd.CancelEvent



.



.



.


.
 
Open the main form in design view. Click on the outside of the control that
"is" the subform (contains the subform). Click on Properties icon on
toolbar. Click on Event tab. You'll see it there.

--

Ken Snell
<MS ACCESS MVP>

I am confused, I don't see an On Enter property?
-----Original Message-----
There is an On Enter property for the main form's control that holds the
subform. You're looking at the form that is serving as the subform -- and
no, it doesn't contain this property.

--

Ken Snell
<MS ACCESS MVP>

Therer is no OnEnter event for the subform and the Got
Focus event did not work either.
here is my code:

If IsNull(Me.Applicant!txtApplicant1) Then
MsgBox "You must enter the Applicant's Last Name"
Cancel = True
Me!Applicant!txtApplicant1.SetFocus
End If
-----Original Message-----
What I suggest is that you put code in the subform's
OnEnter event that
tests for the presence or absence of info in that
textbox. If there is info,
then the code ends. If there is not info, then the code
displays the error
message, sets the focus back to that control, and then
ends.

--

Ken Snell
<MS ACCESS MVP>

I added the msgbox in the onexit for the control of the
txtApplicant1 because if the userclicks on the subform
and enters data I get an error message that the main
form
required data in the autonumber (the autonumber does
not
increase until data has been entered in the main form).
Basically, this works but when I try to click on Find
or
Close I without any data entered in the txtApplicant1 I
recieve the message box to enter data. Hope this makes
more sense, and thanks for your help.
-----Original Message-----
I am not understanding. You don't want to force an
entry
into the textbox
before the user can click into the subform? Or you do
want to force the
entry? I do not unsderstand why the control's
BeforeUpdate event "stopping"
the form's BeforeUpdate event is bad?

Perhaps you can explain in more detail what you want
the
form to do and what
you want the user to do.

--

Ken Snell
<MS ACCESS MVP>

In the BeforeUpdate event of the form I have code to
ask
the user if they would like to save the current
record,
before adding date to the subform.
If MsgBox("Save Changes to Applicant Record?",
vbYesNo) =
vbNo Then
'Cancel = True
Me.Undo
End If
I added this because when I clicked on a field in
the
subform before entering any data in the mainform I
received an error - to do with the primary key on
the
main form not having any data - it is an
autonumber. Is
there any way other way to check if data was not
entered
in the Applicant1 text box. If I did put the code in
the
OnBeforeUpdate it stopped the OnBeforeUpdate for the
form
to stop working...thanks again
-----Original Message-----
Additionally, use the control's OnBeforeUpdate
event
for
your code, not the
OnExit event.

--

Ken Snell
<MS ACCESS MVP>

in
message
I have added code to verify a user is entering in
information for an Applicant form to correspond
with
sub-
form. However this msgbox continously pops up and
won't
let me click the close button or find in case the
user
did not want to add a new applicant. The Msgbox
is
in
the
on exit of the control of the Applicant's last
name.

ex.
If IsNull([Applicant1 Last Name]) Then
MsgBox "You must enter the Applicant's Last Name"
DoCmd.CancelEvent



.



.



.


.
 
I found it and it works great! You have been such a big
help. Could you answer another question. How do I find on
the subform if the FindRecord is on the Main Form. I have
the Find Record looking in the subform but it states no
records are found. Thanks again.
-----Original Message-----
I am confused, I don't see an On Enter property?
-----Original Message-----
There is an On Enter property for the main form's control that holds the
subform. You're looking at the form that is serving as the subform -- and
no, it doesn't contain this property.
of
you
mainform
for
up
case
the
user
did not want to add a new applicant. The Msgbox
is
in
the
on exit of the control of the Applicant's last
name.

ex.
If IsNull([Applicant1 Last Name]) Then
MsgBox "You must enter the Applicant's Last Name"
DoCmd.CancelEvent



.



.



.


.
.
 
I found it and it works great! You have been such a big
help. Could you answer another question. How do I find on
the subform if the FindRecord is on the Main Form. I have
the Find Record looking in the subform but it states no
records are found. Thanks again.
-----Original Message-----
Open the main form in design view. Click on the outside of the control that
"is" the subform (contains the subform). Click on Properties icon on
toolbar. Click on Event tab. You'll see it there.

--

Ken Snell
<MS ACCESS MVP>

I am confused, I don't see an On Enter property?
-----Original Message-----
There is an On Enter property for the main form's control that holds the
subform. You're looking at the form that is serving as the subform -- and
no, it doesn't contain this property.

--

Ken Snell
<MS ACCESS MVP>

Therer is no OnEnter event for the subform and the Got
Focus event did not work either.
here is my code:

If IsNull(Me.Applicant!txtApplicant1) Then
MsgBox "You must enter the Applicant's Last Name"
Cancel = True
Me!Applicant!txtApplicant1.SetFocus
End If
-----Original Message-----
What I suggest is that you put code in the subform's
OnEnter event that
tests for the presence or absence of info in that
textbox. If there is info,
then the code ends. If there is not info, then the code
displays the error
message, sets the focus back to that control, and then
ends.

--

Ken Snell
<MS ACCESS MVP>

I added the msgbox in the onexit for the control
of
the
txtApplicant1 because if the userclicks on the subform
and enters data I get an error message that the main
form
required data in the autonumber (the autonumber does
not
increase until data has been entered in the main form).
Basically, this works but when I try to click on Find
or
Close I without any data entered in the txtApplicant1 I
recieve the message box to enter data. Hope this makes
more sense, and thanks for your help.
-----Original Message-----
I am not understanding. You don't want to force an
entry
into the textbox
before the user can click into the subform? Or
you
do
want to force the
entry? I do not unsderstand why the control's
BeforeUpdate event "stopping"
the form's BeforeUpdate event is bad?

Perhaps you can explain in more detail what you want
the
form to do and what
you want the user to do.

--

Ken Snell
<MS ACCESS MVP>

In the BeforeUpdate event of the form I have code to
ask
the user if they would like to save the current
record,
before adding date to the subform.
If MsgBox("Save Changes to Applicant Record?",
vbYesNo) =
vbNo Then
'Cancel = True
Me.Undo
End If
I added this because when I clicked on a field in
the
subform before entering any data in the
mainform
I
received an error - to do with the primary key on
the
main form not having any data - it is an
autonumber. Is
there any way other way to check if data was not
entered
in the Applicant1 text box. If I did put the code in
the
OnBeforeUpdate it stopped the OnBeforeUpdate
for
the
form
to stop working...thanks again
-----Original Message-----
Additionally, use the control's OnBeforeUpdate
event
for
your code, not the
OnExit event.

--

Ken Snell
<MS ACCESS MVP>

in
message
[email protected]...
I have added code to verify a user is entering in
information for an Applicant form to correspond
with
sub-
form. However this msgbox continously pops
up
and
won't
let me click the close button or find in
case
the
user
did not want to add a new applicant. The Msgbox
is
in
the
on exit of the control of the Applicant's last
name.

ex.
If IsNull([Applicant1 Last Name]) Then
MsgBox "You must enter the Applicant's Last Name"
DoCmd.CancelEvent



.



.



.



.


.
 
I'm sorry, I'm not understanding your question. Can you post some code that
you're trying to use so that I can see what you're trying to do?
 
Private Sub cmdFindRecord_Click()
On Error GoTo Err_cmdFindRecord_Click


Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, ,
acMenuVer70

Exit_cmdFindRecord_Click:
Exit Sub

Err_cmdFindRecord_Click:
MsgBox Err.Description
Resume Exit_cmdFindRecord_Click

End Sub

This is the code for the Find Record command button.
However, it does not find records for the sub form,
although I can choose to look in the subform. thanks.
 
Are you trying to run this code from the main form and find something on the
subform? Why not put a command button on the subform that will do this for
you, and use the same code?
 
Back
Top