473,378 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 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 4007
-----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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: bob bob via AccessMonster.com | last post by:
I'm sure this is a simple one. I have a combo box that, when its data is changed, will trigger a second form to open for input. If the operator declines input, I want the combo box to return to...
15
by: simonmarkjones | last post by:
I want to validate my form using a BeforeUpdate event. However now that i call my code with a beforeupdate it wont let me go to next or previous records. What code should i put in o allow me...
9
by: simonmarkjones | last post by:
I want to call a function which does this when the next record button is pressed (calling it from before update) if textboxes are empty then Message box you must fill text box
2
by: PC Datasheet | last post by:
In a form/subform I have an unbound combobox in the form header that sets the value of a field in the subform so that it does not have to be entered for each record. In the BeforeUpdate event of...
6
by: lorirobn | last post by:
Hi, I have a form with a continuous subform. I am working on putting validations in for the subform's required fields. Being somewhat new to Access (or rather, an antiquated mainframe...
6
by: tlyczko | last post by:
I have a BeforeUpdate where I need to ensure that no matter what, the first four fields on the form (one text box, 3 combo box lists) have data entered in them before the user closes the form or...
3
by: tlyczko | last post by:
Hello, I think what I'm asking for may not be possible, but I'll try anyway. I have MainForm with 3 subforms, one SubForm requires data entry, the other two don't (optional). MainForm has...
2
by: thatguyNYC | last post by:
Hello-- I have a form that lets the user edit the values in a lookup table. The form is bound to a table and has one textbox on it. The record nav buttons are enabled. On the top half of the...
7
by: john.cole | last post by:
I have searched all the groups I can, and I still haven't been able to come up the solution I need. I have the following problem. In my form named sbfrmSpoolList, I am entering a job, spool and...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.