A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

checking a field in a form before update



 
 
Thread Tools Display Modes
  #1  
Old November 9th, 2009, 01:43 PM posted to microsoft.public.access.forms
leahf via AccessMonster.com
external usenet poster
 
Posts: 54
Default checking a field in a form before update

In an existing form that shows teacher details, there is a field for the
teacher id number (similar to a social security number). This field is shown
in a text box but until now has never been checked for validity.

From now on, if anyone wants to update this id number, a script will check
the number. If it is not valid, there should be an error message displayed
and, if the user wants to correct the field, the form should remain open with
the cursor pointing to the field.

In the BeforeUpdate of the form, I can use a message reponse box. If the
user wants to update the field, how do I make sure that the cursor remains in
the text box and the user cannot exit the form?

Thanks.
Leah

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200911/1

  #2  
Old November 9th, 2009, 02:19 PM posted to microsoft.public.access.forms
Stefan Hoffmann
external usenet poster
 
Posts: 991
Default checking a field in a form before update

hi Leah,

leahf via AccessMonster.com wrote:
In the BeforeUpdate of the form, I can use a message reponse box. If the
user wants to update the field, how do I make sure that the cursor remains in
the text box and the user cannot exit the form?

Use

txtTeacherId.SetFocus

in the Before Update event to set the focus into your text box.
Also set

Cancel = True

if the ID is not valid. This will automatically raise an error message
when the user tries to exit the form with an unsaved recordset.



mfG
-- stefan --
  #3  
Old November 10th, 2009, 06:27 AM posted to microsoft.public.access.forms
leahf via AccessMonster.com
external usenet poster
 
Posts: 54
Default checking a field in a form before update

Hi Stefan,

I had tried that. Let me try to explain:

The form is defined to automatically update the information upon exiting the
form (rather than have buttons for update or exit without saving). What I
tried to do is to check the id Number on the BeforeUpdate of the form.

If it is not correct I have a ResponseMessage.

If the user does not want to change anything, I have cancel = true, exit and
the data remains as it was.

If the user does want to go back to change the id number, I wanted to
setFocus to the field and let it "sit there". However, it exits the whole
form (saving the new data if cancel=true is not in the script, or restoring
the original data if cancel=true is in the script).

What I think is happening, is that when it leaves the BeforeUpdate form event,
it continues the cycle and exits. I am trying to stop that cycle.

Thanks.
Leah

Stefan Hoffmann wrote:
hi Leah,

In the BeforeUpdate of the form, I can use a message reponse box. If the
user wants to update the field, how do I make sure that the cursor remains in
the text box and the user cannot exit the form?

Use

txtTeacherId.SetFocus

in the Before Update event to set the focus into your text box.
Also set

Cancel = True

if the ID is not valid. This will automatically raise an error message
when the user tries to exit the form with an unsaved recordset.

mfG
-- stefan --


--
Message posted via http://www.accessmonster.com

  #4  
Old November 10th, 2009, 07:28 AM posted to microsoft.public.access.forms
leahf via AccessMonster.com
external usenet poster
 
Posts: 54
Default checking a field in a form before update

Hi Stefan,

I just switched the checking of the field on the BeforeUpdate of the text box
instead of the form, and everything seems to be working.

Thanks for your help.
Leah


Stefan Hoffmann wrote:
hi Leah,

In the BeforeUpdate of the form, I can use a message reponse box. If the
user wants to update the field, how do I make sure that the cursor remains in
the text box and the user cannot exit the form?

Use

txtTeacherId.SetFocus

in the Before Update event to set the focus into your text box.
Also set

Cancel = True

if the ID is not valid. This will automatically raise an error message
when the user tries to exit the form with an unsaved recordset.

mfG
-- stefan --


--
Message posted via http://www.accessmonster.com

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:34 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.