Macro not running correctly on form

  • Thread starter Thread starter ChuckW
  • Start date Start date
C

ChuckW

Hi,

I have two tables - Attendees and MailingList, with a
common field called ID. The Attendees tables had name,
address, phone and a field called Inactive. There is a
continuous form called AddAttendees which is designed to
make changes to the Attenddes table. On this form is a
checkbox called "Inactive". What I am trying to do is to
delete everyone in the MailingList table who had a check
in the Inactive field of the AddAttendees form.

I created a delete query which will successfully do
this. I then created a macro called CloseAndDelete.
What it does is to Close the AddAttendees form and run my
delete query. I have a lable called Exit - it appear to
the user as an exit button for getting out of the
AddAttendee form. The problem is that when I mark
several people as inactive, and then click the exit
button (ie my macro) and then check the MailingList
table, the last record does not get deleted. If I mark
several people as inactive and then press my tab key and
then exit (run my macro) it does work.

In my macro I created a SendKeys and typed in "{tab}" but
this didn't solve the problem. For some reason it is not
recognizing my last selection of inactivating someone.
When I run the macro separately it does work.

Can anyone help?

Thanks,

Chuck
 
In my macro I created a SendKeys and typed in "{tab}" but
this didn't solve the problem. For some reason it is not
recognizing my last selection of inactivating someone.

It's probably failing because the last record is currently still
active on the screen, and has not yet been saved to disk. Rather than
using the (flaky and unreliable) Sendkeys macro, I'd suggest executing
a SaveRecord action to write the record to disk.


John W. Vinson[MVP]
(no longer chatting for now)
 
John,

Thanks for your help. Can you give me a little more info
on how to save a record. Should I do it outside of a
macro? Right now I had a button that runs a macro that
closes the form and runs my delete query. Is there a
better way to do this?

Thanks,

Chuck
 
John,

Thanks for your help. Can you give me a little more info
on how to save a record. Should I do it outside of a
macro? Right now I had a button that runs a macro that
closes the form and runs my delete query. Is there a
better way to do this?

I'm not at all knowlegable about macros; I find that absolutely
anything that you can do with a macro can be done more flexibly and
more securely in VBA code. Take a look at the online help for
RunCommand - SaveRecord is one of the commands that you can run.

I'm not certain what you intend the macro to accomplish, or I'd
suggest how to recast it as VBA code.

John W. Vinson[MVP]
(no longer chatting for now)
 
One can use the SetValue macro action to set the Dirty property of the form
to False:

SetValue
Item: Forms!FormName.Dirty
Expression: False

This should be one way to use a macro to save a record!
 
Back
Top