PC Review


Reply
Thread Tools Rate Thread

Can't undo a form's TextBox entry that has a validation rule

 
 
John S. Ford, MD
Guest
Posts: n/a
 
      17th Apr 2009
I'm using Access 2000.

I have a TextBox on a form bound to a field of the form's underlying table
with the following settings:
ValidationRule = Like "####"
ValidationText = "You must enter four consecutive numbers."

The form also has an "Undo" button that is supposed to undo whatever record
entry has been attempted and closes the form. Unfortunately, if the user
enters invalid data into the TextBox, I can't click on the Undo button
because each time I try to do so, the focus leaves the TextBox and the
validation routine gets triggered. When the resulting message box is
closed, the focus goes right back to the Textbox, the Undo button can never
be clicked, the form can therefore never be "undone", and it can't be
closed.

How can I stop this continuous loop from occurring?

John


 
Reply With Quote
 
 
 
 
KARL DEWEY
Guest
Posts: n/a
 
      17th Apr 2009
Try this --
ValidationRule = Like "####" OR Null

and then just backspace the characters out.

"John S. Ford, MD" wrote:

> I'm using Access 2000.
>
> I have a TextBox on a form bound to a field of the form's underlying table
> with the following settings:
> ValidationRule = Like "####"
> ValidationText = "You must enter four consecutive numbers."
>
> The form also has an "Undo" button that is supposed to undo whatever record
> entry has been attempted and closes the form. Unfortunately, if the user
> enters invalid data into the TextBox, I can't click on the Undo button
> because each time I try to do so, the focus leaves the TextBox and the
> validation routine gets triggered. When the resulting message box is
> closed, the focus goes right back to the Textbox, the Undo button can never
> be clicked, the form can therefore never be "undone", and it can't be
> closed.
>
> How can I stop this continuous loop from occurring?
>
> John
>
>
>

 
Reply With Quote
 
John S. Ford, MD
Guest
Posts: n/a
 
      17th Apr 2009
This field is a required field so NULL is not a valid entry.

John

"KARL DEWEY" <(E-Mail Removed)> wrote in message
news:59436F0A-7E2E-44D5-878A-(E-Mail Removed)...
> Try this --
> ValidationRule = Like "####" OR Null
>
> and then just backspace the characters out.



 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      17th Apr 2009
"John S. Ford, MD" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm using Access 2000.
>
> I have a TextBox on a form bound to a field of the form's underlying table
> with the following settings:
> ValidationRule = Like "####"
> ValidationText = "You must enter four consecutive numbers."
>
> The form also has an "Undo" button that is supposed to undo whatever
> record entry has been attempted and closes the form. Unfortunately, if
> the user enters invalid data into the TextBox, I can't click on the Undo
> button because each time I try to do so, the focus leaves the TextBox and
> the validation routine gets triggered. When the resulting message box is
> closed, the focus goes right back to the Textbox, the Undo button can
> never be clicked, the form can therefore never be "undone", and it can't
> be closed.
>
> How can I stop this continuous loop from occurring?



Normally you press {Esc} to undo the invalid entry in the control. Have you
tried that?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 
Reply With Quote
 
John S. Ford, MD
Guest
Posts: n/a
 
      17th Apr 2009
Yes but then I'd have to depend on my user knowing that. Isn't there a way
of doing this programmatically via a command button?

I know that with VB.net, you can set a button's CausesValidation = False to
prevent a validation routine from occurring in a TextBox elsewhere. This is
typically used with programmer-created "Undo", "Cancel", or "Help" buttons.
Is there no comparable property in VBA?

John

> Normally you press {Esc} to undo the invalid entry in the control. Have
> you tried that?
>
> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com



 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      17th Apr 2009
"John S. Ford, MD" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Yes but then I'd have to depend on my user knowing that. Isn't there a
> way of doing this programmatically via a command button?
>
> I know that with VB.net, you can set a button's CausesValidation = False
> to prevent a validation routine from occurring in a TextBox elsewhere.
> This is typically used with programmer-created "Undo", "Cancel", or "Help"
> buttons. Is there no comparable property in VBA?



No. Of course, you can always have your ValidationText message tell the
user what to do:

"You must enter four consecutive numbers. Correct your entry, or press
{Esc} to undo it."


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      17th Apr 2009
"John S. Ford, MD" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Yes but then I'd have to depend on my user knowing that. Isn't there a
> way of doing this programmatically via a command button?



Come to think of it, you can probably do it with a toolbar button -- not a
command button, but a button on the toolbar.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 
Reply With Quote
 
Albert D. Kallal
Guest
Posts: n/a
 
      17th Apr 2009
"John S. Ford, MD" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Yes but then I'd have to depend on my user knowing that. Isn't there a
> way of doing this programmatically via a command button?
>
> I know that with VB.net, you can set a button's CausesValidation = False
> to prevent a validation routine from occurring in a TextBox elsewhere.
> This is typically used with programmer-created "Undo", "Cancel", or "Help"
> buttons. Is there no comparable property in VBA?
>


Unfortunately we don't have that feature.

However, I not 100% sure if we had the causesVAlidation feature that would
really fix this problem.

Unless you are going to allow the focus to move away from that control then
you can't run the code to do the undo.

The standard windows way is to use the menu bar and go

edit->undo

This works in word, excel, access etc. So, it is very much standard option
in applications that your users will have been exposed to.

I usually build custom menu bars for my applications, and this again solves
the above problem. It also means that you can hide all of the ms-access
interface without have to run special code to hide things.

There is some nice screen shots of access menus in the following link:
I talk about the approach I use to build menu bars here:
http://www.members.shaw.ca/AlbertKal...erFriendly.htm

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(E-Mail Removed)


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't undo a form's TextBox entry that has a validation rule John S. Ford, MD Microsoft Access Forms 7 17th Apr 2009 08:33 PM
Can't undo a form's TextBox entry that has a validation rule John S. Ford, MD Microsoft Access Form Coding 7 17th Apr 2009 08:33 PM
Validation rule to prevent entry =?Utf-8?B?c2ltb25j?= Microsoft Access 6 24th May 2006 12:51 PM
Validation rule to prevent entry =?Utf-8?B?c2ltb25j?= Microsoft Access 0 23rd May 2006 07:37 PM
need help with textbox validation rule =?Utf-8?B?SmVmZg==?= Microsoft Access Form Coding 1 22nd Jun 2005 11:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:57 AM.