checking a field in a form before update

  • Thread starter leahf via AccessMonster.com
  • Start date
L

leahf via AccessMonster.com

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
 
S

Stefan Hoffmann

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 <--
 
L

leahf via AccessMonster.com

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
 
L

leahf via AccessMonster.com

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top