"Set Warnings" action

  • Thread starter Thread starter Robin
  • Start date Start date
R

Robin

A frustration for your consideration and help, please: I
have a macro which is working fine EXCEPT that the "Set
Warnings" action seems to not work as promised. This
macro is triggered by the "NotInList" event when an entry
made into a form's combo box is not on the lookup list.
All of the macro's actions function properly AFTER an
error box appears, announcing that "the entry is not on
the lookup list" -- when I then press ENTER (i.e., "OK" in
that error window), the macro proceeds to do what it's
supposed to do, i.e., it creates a new record in the
lookup's underlying table, adds the new entry to the
table, then, on the form, refreshes the combo box's lookup
list, enters the "new" entry, and tabs to the next field.

Why is the "Set Warnings" action not suppressing that
error box? (The box doesn't actually say "error": it has
an "i" in a balloon...)

The macro: ECHO (no), SET WARNINGS (no), SENDKEYS
({F2},Yes), RUNCOMMAND (Copy), RUNCOMMAND (Delete),
SENDKEYS ({ESC}{ESC},Yes), OPENTABLE
(BrandNames,Datasheet,Add), SENDKEYS ({TAB},Yes),
RUNCOMMAND (Paste), CLOSE (Table,BrandNames,Yes),
RUNCOMMAND (Refresh), RUNCOMMAND (Paste), SENDKEYS
({TAB},Yes)

I tried two things which did NOT succeed in suppressing
that error box: 1) I reversed the order of the first two
commands -- SET WARNINGS, then ECHO; 2) I added an ENTER
command to simulate my clicking on the "OK" button in the
box. The first solution had no effect. The second one
caused the program to crash!

Your help will be appreciated.
 
G’day Robin.

Please bear with me if I get something wrong, my first post you know…

This statement should offend no one: -
Macro’s are like training wheels on a bicycle, once you get your
balance they should be dispensed with.

There are a number of things wrong, but in no particular order: -

With the possible exception of the AutoExec Macro, don’t use Macro’s.
Except when absolutely necessary, don’t use SendKeys.
Please try to convert all Macro’s to VBA, more flexibility and you can
handle errors.
Don’t believe that the conversion will produce the best VBA available.
If you’re starting out, it will be a hard, but worthwhile, slog.

As to your question…
I don’t know; it could be that the database is set-up to break on all
errors.
(This produces some remarkable results sometimes.)

So that we can see just what is going on, can you convert the Macro to
VBA?
Can you supply a cutdown version of the error as a demo?

Regards,
Chris.
 
The SetWarnings message does not apply to the error message that you get in
the NotInList event. That event cannot be properly handled by a macro, as
you must set a variable to a value in that event in order to suppress the
message that you're seeing.

See this URL for more info and some sample VBA code (The ACCESS Web):
http://www.mvps.org/access/forms/frm0015.htm
 
Back
Top