472,093 Members | 2,547 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,093 software developers and data experts.

BeforeUpdate problem with Multiple Page Form

Hello Everyone,

Access 2000

I have a form with multiple pages on it. There is one text field
[SupervisoryStatus] on the third page of the form that I need the user to
complete before leaving the form or moving to the next record.

So, in the BeforeUpdate event of the form itself I have the following code:

If Len(Me.SupervisoryStatus & "") = 0 Then
MsgBox "Please Indicate Supervisory Status."
DoCmd.CancelEvent
Me.SupervisoryStatus.SetFocus
End If

If this text field is blank and the user tries to leave the record or form,
it sends the user to the field so they can complete it. It works fine
except for one problem. If the user clicks on another page (clicks on the
tab) on the form, access thinks the user is trying to move to another record
so the BeforeUpdate event fires. I want the user to be able to move from
page to page without it firing, but I want it to execute if they actually
try to leave the form, or move to another record if the field is left blank.

This same problem occurs if I make the field a required field in the table.

Thanks for your help.

William

Nov 12 '05 #1
4 3843
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Do you have any subforms on the form? Is the user moving to the page
that holds that subform? If the user has made some edits/adds to the
main form and moves to the subform, the main form's BeforeUpdate event
runs.

The form BeforeUpdate event ONLY runs when a change/add has been made
to the record. Therefore, if the user hasn't made any changes to the
record when they move to another page/tab (subform) on the form, the
BeforeUpdate event shouldn't run. Is there some macro or code that
runs when the form opens, or on movement to another record, that puts
a value into one of the bound controls? This will cause the form to
be in edit mode, which will cause the BeforeUpdate event to run when
the user moves to a subform or moves to another record or closes the
form.

MGFoster:::mgf
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP7lhu4echKqOuFEgEQLtJgCffcOoJwlSsjTSWCQQwz7Vop hG7mYAn0WL
7u1wKgRVRaC3uPDjXXbjw0dg
=x5lf
-----END PGP SIGNATURE-----
William Wisnieski wrote:
Hello Everyone,

Access 2000

I have a form with multiple pages on it. There is one text field
[SupervisoryStatus] on the third page of the form that I need the user to
complete before leaving the form or moving to the next record.

So, in the BeforeUpdate event of the form itself I have the following code:

If Len(Me.SupervisoryStatus & "") = 0 Then
MsgBox "Please Indicate Supervisory Status."
DoCmd.CancelEvent
Me.SupervisoryStatus.SetFocus
End If

If this text field is blank and the user tries to leave the record or form,
it sends the user to the field so they can complete it. It works fine
except for one problem. If the user clicks on another page (clicks on the
tab) on the form, access thinks the user is trying to move to another record
so the BeforeUpdate event fires. I want the user to be able to move from
page to page without it firing, but I want it to execute if they actually
try to leave the form, or move to another record if the field is left blank.

This same problem occurs if I make the field a required field in the table.

Nov 12 '05 #2
Thanks for your reply. Yes, you're exactly right, I do have some subforms
on different pages. The users bounce down to the subform on different pages
of the main form. The field in question [SupervisoryStatus] is on the main
form however. Any suggestions on what code I should use to solve my
problem?

Thank you.

William
"MGFoster" <me@privacy.com> wrote in message
news:2l*****************@newsread1.news.pas.earthl ink.net...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Do you have any subforms on the form? Is the user moving to the page
that holds that subform? If the user has made some edits/adds to the
main form and moves to the subform, the main form's BeforeUpdate event
runs.

The form BeforeUpdate event ONLY runs when a change/add has been made
to the record. Therefore, if the user hasn't made any changes to the
record when they move to another page/tab (subform) on the form, the
BeforeUpdate event shouldn't run. Is there some macro or code that
runs when the form opens, or on movement to another record, that puts
a value into one of the bound controls? This will cause the form to
be in edit mode, which will cause the BeforeUpdate event to run when
the user moves to a subform or moves to another record or closes the
form.

MGFoster:::mgf
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP7lhu4echKqOuFEgEQLtJgCffcOoJwlSsjTSWCQQwz7Vop hG7mYAn0WL
7u1wKgRVRaC3uPDjXXbjw0dg
=x5lf
-----END PGP SIGNATURE-----
William Wisnieski wrote:
Hello Everyone,

Access 2000

I have a form with multiple pages on it. There is one text field
[SupervisoryStatus] on the third page of the form that I need the user to complete before leaving the form or moving to the next record.

So, in the BeforeUpdate event of the form itself I have the following code:
If Len(Me.SupervisoryStatus & "") = 0 Then
MsgBox "Please Indicate Supervisory Status."
DoCmd.CancelEvent
Me.SupervisoryStatus.SetFocus
End If

If this text field is blank and the user tries to leave the record or form, it sends the user to the field so they can complete it. It works fine
except for one problem. If the user clicks on another page (clicks on the tab) on the form, access thinks the user is trying to move to another record so the BeforeUpdate event fires. I want the user to be able to move from page to page without it firing, but I want it to execute if they actually try to leave the form, or move to another record if the field is left blank.
This same problem occurs if I make the field a required field in the
table.

Nov 12 '05 #3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

To prevent users from saving a record before all "required" data has
been entered I put a DataOK function call in the main form's
BeforeUpdate event - much like the check you had for data in the
SupervisoryStatus. E.g.:

Private Sub Form_BeforeUpdate(Cancel As Integer)

Cancel = Not DataOK()

End Sub

The function DataOK checks for the existence of required data & if
DataOK = False gives an error message "Required Data Missing" & a list
of fields that require data & returns False to the Form's BeforeUpdate
event, which sets Cancel to True & stops the save of the main form's
record.

For subforms I've also used the subform control's OnEnter event to
call the DataOK function. If the DataOK function returns False the
OnEnter event sets the focus to a Control on the main form. This way
the user can't enter the subforms before all required data on the main
form has been entered.

HTH,

MGFoster:::mgf
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP7nn24echKqOuFEgEQL7CgCgrhaTi5mcLJGZHjhN68EEk9 9EvNIAnRMv
KyB/UlwL5Hw3SVbyB9b0MhCs
=rzoo
-----END PGP SIGNATURE-----

William Wisnieski wrote:
Thanks for your reply. Yes, you're exactly right, I do have some subforms
on different pages. The users bounce down to the subform on different pages
of the main form. The field in question [SupervisoryStatus] is on the main
form however. Any suggestions on what code I should use to solve my
problem?

Thank you.

William
"MGFoster" <me@privacy.com> wrote in message
news:2l*****************@newsread1.news.pas.earthl ink.net...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Do you have any subforms on the form? Is the user moving to the page
that holds that subform? If the user has made some edits/adds to the
main form and moves to the subform, the main form's BeforeUpdate event
runs.

The form BeforeUpdate event ONLY runs when a change/add has been made
to the record. Therefore, if the user hasn't made any changes to the
record when they move to another page/tab (subform) on the form, the
BeforeUpdate event shouldn't run. Is there some macro or code that
runs when the form opens, or on movement to another record, that puts
a value into one of the bound controls? This will cause the form to
be in edit mode, which will cause the BeforeUpdate event to run when
the user moves to a subform or moves to another record or closes the
form.

MGFoster:::mgf
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP7lhu4echKqOuFEgEQLtJgCffcOoJwlSsjTSWCQQwz7Vop hG7mYAn0WL
7u1wKgRVRaC3uPDjXXbjw0dg
=x5lf
-----END PGP SIGNATURE-----
William Wisnieski wrote:

Hello Everyone,

Access 2000

I have a form with multiple pages on it. There is one text field
[SupervisoryStatus] on the third page of the form that I need the user
to
complete before leaving the form or moving to the next record.

So, in the BeforeUpdate event of the form itself I have the following
code:
If Len(Me.SupervisoryStatus & "") = 0 Then
MsgBox "Please Indicate Supervisory Status."
DoCmd.CancelEvent
Me.SupervisoryStatus.SetFocus
End If

If this text field is blank and the user tries to leave the record or
form,
it sends the user to the field so they can complete it. It works fine
except for one problem. If the user clicks on another page (clicks on
the
tab) on the form, access thinks the user is trying to move to another
record
so the BeforeUpdate event fires. I want the user to be able to move
from
page to page without it firing, but I want it to execute if they
actually
try to leave the form, or move to another record if the field is left
blank.
This same problem occurs if I make the field a required field in the


table.



Nov 12 '05 #4
rkc

"William Wisnieski" <wi***************@verizon.net> wrote in message
news:%0*******************@nwrdny02.gnilink.net...
Hello Everyone,

Access 2000

I have a form with multiple pages on it. There is one text field
[SupervisoryStatus] on the third page of the form that I need the user to
complete before leaving the form or moving to the next record.

So, in the BeforeUpdate event of the form itself I have the following code:
If Len(Me.SupervisoryStatus & "") = 0 Then
MsgBox "Please Indicate Supervisory Status."
DoCmd.CancelEvent
Me.SupervisoryStatus.SetFocus
End If

If this text field is blank and the user tries to leave the record or form, it sends the user to the field so they can complete it. It works fine
except for one problem. If the user clicks on another page (clicks on the
tab) on the form, access thinks the user is trying to move to another record so the BeforeUpdate event fires. I want the user to be able to move from
page to page without it firing, but I want it to execute if they actually
try to leave the form, or move to another record if the field is left

blank.

This happens when you have a subForm on a tab. It's the same as setting
focus to a seperate form. The only solution I know of is to create a record
source for the main form that contains every field you need to make an
entry.

Could be solutions I don't know of though.
Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by bob bob via AccessMonster.com | last post: by
15 posts views Thread by simonmarkjones | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.