Clearing form after error

N

NES

When an item entered into a drop down box is not found, I have the
application bring up a form so that the item with appripriate info can be
entered. When that form is closed I am returned to the original form which is
which is fine. However, the erroneously entered information remains. Pressing
the ESC key twice clears everything and makes it ready for new entry.

How can I automate the clearing of this form rather than having the operator
remember to hit the ESC key twice?

My thanks to anyone who may wish to tackle this problem.
 
R

roger

lookup "CancelEvent" which undoes events

or just use
Forms!Myform.MyControl =""
for each field
hth
 
N

NES

Roger, I added the CancelEvent to the beginning of the macro that opens up
the new form, but it does not clear previous form.

I've tried using the SendKeys {esc} twice before calling the other form, but
that doesn't work either.
 
N

NES

Roger, I just discovered that the form for SendKeys is {escape} rather than
{esc}. Placing this at the beginning of the macro that calls up the other
forms works. Thank for your input.
 
M

monma01 via AccessMonster.com

NES said:
Roger, I added the CancelEvent to the beginning of the macro that opens up
the new form, but it does not clear previous form.

I've tried using the SendKeys {esc} twice before calling the other form, but
that doesn't work either.
lookup "CancelEvent" which undoes events
[quoted text clipped - 13 lines]

If you just need to clear the data from the combo box, see the help about the
NotInList Event:

The NotInList event occurs when the user enters a value in the text box
portion of a combo box that isn't in the combo box list.

Private Sub object_NotInList(NewData As String, Response As Integer)
Object The name of a combo box control.

NewData A string that Microsoft Access uses to pass the text the user
entered in the text box portion of the combo box to the event procedure.

Response The setting indicates how the NotInList event was handled. The
Response argument can be one of the following intrinsic constants:

Constant Description

acDataErrDisplay (Default) Displays the default message to the user. You can
use this when you don't want to allow the user to add a new value to the
combo box list.

acDataErrContinue Doesn't display the default message to the user. You can
use this when you want to display a custom message to the user. For example,
the event procedure could display a custom dialog box asking if the user
wanted to save the new entry. If the response is Yes, the event procedure
would add the new entry to the list and set the Response argument to
acDataErrAdded. If the response is No, the event procedure would set the
Response argument to acDataErrContinue.

acDataErrAdded Doesn't display a message to the user but enables you to add
the entry to the combo box list in the NotInList event procedure. After the
entry is added, Microsoft Access updates the list by requerying the combo box.
Microsoft Access then rechecks the string against the combo box list, and
saves the value in the NewData argument in the field the combo box is bound
to. If the string is not in the list, then Microsoft Access displays an error
message.
 
R

roger

sendkeys is not good. (it often turns numlock off, and and if anything pops
up it sends escape to that window)

setting the values back to null is better

Forms!Myform.MyControl =""
(or)
me.mycontrol=""
 
N

NES

I have heard that before, and have no reason to questions it. However, I'm am
not VBA literate. There are two things occurring.

1) erroneous data remains in the drop down box
2) the record has been opened and remains so

That is why I need to send ESCAPE twice.

I don't know where to place your suggested code. Indeed, with a dropdown box
I can't seem to find code in VB mode which I can modify or add to.

I know that experienced programmers eschew many things which Access has
provided for the rest of us dunces. So, sorry to say I cannot use your valued
advise at this time. I would be willing to try if I could at least find the
VB code for the control.

I do appreciate your response and concern. Thanks again for your assistance.
 
J

J_Goddard via AccessMonster.com

Hi -

Try using me![mycontrol].undo to undo the change to just the combo box, or Me.
undo to undo the changes in all the fields in the form.


John

I have heard that before, and have no reason to questions it. However, I'm am
not VBA literate. There are two things occurring.

1) erroneous data remains in the drop down box
2) the record has been opened and remains so

That is why I need to send ESCAPE twice.

I don't know where to place your suggested code. Indeed, with a dropdown box
I can't seem to find code in VB mode which I can modify or add to.

I know that experienced programmers eschew many things which Access has
provided for the rest of us dunces. So, sorry to say I cannot use your valued
advise at this time. I would be willing to try if I could at least find the
VB code for the control.

I do appreciate your response and concern. Thanks again for your assistance.
sendkeys is not good. (it often turns numlock off, and and if anything pops
up it sends escape to that window)
[quoted text clipped - 26 lines]
 
N

NES

I don't know where to place your suggested code. Indeed, with a dropdown box
Therein lies the problem. I've tried everything I know, but cannot find a
place to inser this code. Thanks for reaffirming the problems I may face.
I've entered code before, but don't know what to do here. The SendKeys thing
is working for now. If you can briefly explain where ( and perhaps how) to
insert this code, I'd be grateful.

I have done so with command buttons, but drop down boxes are a different
animal. Thanks so much for your help.

--
Norm Shimmel
Butler, PA


J_Goddard via AccessMonster.com said:
Hi -

Try using me![mycontrol].undo to undo the change to just the combo box, or Me.
undo to undo the changes in all the fields in the form.


John

I have heard that before, and have no reason to questions it. However, I'm am
not VBA literate. There are two things occurring.

1) erroneous data remains in the drop down box
2) the record has been opened and remains so

That is why I need to send ESCAPE twice.

I don't know where to place your suggested code. Indeed, with a dropdown box
I can't seem to find code in VB mode which I can modify or add to.

I know that experienced programmers eschew many things which Access has
provided for the rest of us dunces. So, sorry to say I cannot use your valued
advise at this time. I would be willing to try if I could at least find the
VB code for the control.

I do appreciate your response and concern. Thanks again for your assistance.
sendkeys is not good. (it often turns numlock off, and and if anything pops
up it sends escape to that window)
[quoted text clipped - 26 lines]
My thanks to anyone who may wish to tackle this problem.
 
R

roger

Look, where is this SENDKEYS command your using?
Thats where you put ANY of this code!

NES said:
Therein lies the problem. I've tried everything I know, but cannot find a
place to inser this code. Thanks for reaffirming the problems I may face.
I've entered code before, but don't know what to do here. The SendKeys thing
is working for now. If you can briefly explain where ( and perhaps how) to
insert this code, I'd be grateful.

I have done so with command buttons, but drop down boxes are a different
animal. Thanks so much for your help.

--
Norm Shimmel
Butler, PA


J_Goddard via AccessMonster.com said:
Hi -

Try using me![mycontrol].undo to undo the change to just the combo box, or Me.
undo to undo the changes in all the fields in the form.


John

I have heard that before, and have no reason to questions it. However, I'm am
not VBA literate. There are two things occurring.

1) erroneous data remains in the drop down box
2) the record has been opened and remains so

That is why I need to send ESCAPE twice.

I don't know where to place your suggested code. Indeed, with a dropdown box
I can't seem to find code in VB mode which I can modify or add to.

I know that experienced programmers eschew many things which Access has
provided for the rest of us dunces. So, sorry to say I cannot use your valued
advise at this time. I would be willing to try if I could at least find the
VB code for the control.

I do appreciate your response and concern. Thanks again for your assistance.
sendkeys is not good. (it often turns numlock off, and and if anything pops
up it sends escape to that window)
[quoted text clipped - 26 lines]

My thanks to anyone who may wish to tackle this problem.
 
N

NES

Thanks for the clarification. The SendKeys command is in a Macro. I'll check
it out. Thanks again.
--
Norm Shimmel
Butler, PA


roger said:
Look, where is this SENDKEYS command your using?
Thats where you put ANY of this code!

NES said:
I don't know where to place your suggested code. Indeed, with a dropdown box
I can't seem to find code in VB mode which I can modify or add to.

Therein lies the problem. I've tried everything I know, but cannot find a
place to inser this code. Thanks for reaffirming the problems I may face.
I've entered code before, but don't know what to do here. The SendKeys thing
is working for now. If you can briefly explain where ( and perhaps how) to
insert this code, I'd be grateful.

I have done so with command buttons, but drop down boxes are a different
animal. Thanks so much for your help.

--
Norm Shimmel
Butler, PA


J_Goddard via AccessMonster.com said:
Hi -

Try using me![mycontrol].undo to undo the change to just the combo box, or Me.
undo to undo the changes in all the fields in the form.


John


NES wrote:
I have heard that before, and have no reason to questions it. However, I'm am
not VBA literate. There are two things occurring.

1) erroneous data remains in the drop down box
2) the record has been opened and remains so

That is why I need to send ESCAPE twice.

I don't know where to place your suggested code. Indeed, with a dropdown box
I can't seem to find code in VB mode which I can modify or add to.

I know that experienced programmers eschew many things which Access has
provided for the rest of us dunces. So, sorry to say I cannot use your valued
advise at this time. I would be willing to try if I could at least find the
VB code for the control.

I do appreciate your response and concern. Thanks again for your assistance.
sendkeys is not good. (it often turns numlock off, and and if anything pops
up it sends escape to that window)
[quoted text clipped - 26 lines]

My thanks to anyone who may wish to tackle this problem.
 
L

Linq Adams via AccessMonster.com

If you're entering a new record because the value you entered in the combobox
was "Not in list" then you presumably want it "in the list" and to do this
you need to requery the combobox (MyCombobox.Requery) This in turn should
also reset the combobox and get rid of your "erroneous" entry.
 
N

NES

Actually, I tried the requiry in a macro and it didn't work early on. So I'm
using another macro with the "refresh" command. That seems to be working.

I'll try your suggestion. Thank you very much.
 
N

NES

I absolutely appreciate all the suggestions that have been given here.
Unfortunately, I can't apply them. So I shall consider this thread closed.
THanks for all your assistance and comments.
 

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