Disabling Text Box Events on Form OnClose Event

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have code attached to a Text Box's OnExit event that forces the user to
enter a value in this field by giving a warning and setting the Focus back to
this field.

I also have code to run the SetFocus method on this Text Box when a New
Record is entered.

My problem is that if I want to close the screen after data entry and the
user has hit New Record, the Text Box's OnExit event is being called when the
form closes.

The field is a required field, but I don't want the user to fill in all the
fields and then get the error message at the end of the data entry on the
form.

How do I disable the Text Box's event when the form is being closed?
 
You are going to have to stop the user hitting New Record if/when you
don't want him to! If you want control of Navigation, you are likely
to need to remove the standard Navigation arrows completely (which is
very easy, in Form Properties), or replace them with Controls whose
events you can manage, which may be a little mre difficult. You may
want to give us a little more detail about the circumstances under
which you don't want the user to be able to create a New Record.

On Tue, 9 Nov 2004 21:23:03 -0800, "Neill M. Pinkney" <Neill M.
I have code attached to a Text Box's OnExit event that forces the user to
enter a value in this field by giving a warning and setting the Focus back to
this field.

I also have code to run the SetFocus method on this Text Box when a New
Record is entered.

My problem is that if I want to close the screen after data entry and the
user has hit New Record, the Text Box's OnExit event is being called when the
form closes.

The field is a required field, but I don't want the user to fill in all the
fields and then get the error message at the end of the data entry on the
form.

How do I disable the Text Box's event when the form is being closed?


Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 
Hi Peter - Thanks for your response

As hundreds of records are about to be entered, the form has a number of
Text Boxes in a tabbed order. After the last field has been entered, the tab
moves the user to a "New Customer" button, and then back to the first field
for the next screen of data entry.

This first Text Box (and the second) are used for a calculated field on the
form. Because of this I want to prevent the user from exiting either of these
fields if a null or blank value has been entered (hence the code to popup a
warning & refocus on the edit box again).

However after the user has finished for that session, because the "New
Customer" button refocuses back into the first record - I get the errors.

VB & Access are new to me, but in Delphi (my usuaul language), in the
OnClose event of the form I could disable the event from happening by issuing
the equivalant Me! txtFirstame_OnExit = nil anf the event wouldn't run in
this instance.

I have tried moving it to another event of the Text Box, but it either does
the same thing, or will allow me to bat out of the Text Box without entering
a value.

Sorry about the rambling - but you did want more info...
 
Back
Top