422,363 Members | 2,305 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,363 IT Pros & Developers. It's quick & easy.

BeforeUpdate problem with Multiple Page Form

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
-----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

P: n/a
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

P: n/a
-----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

P: n/a
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.