By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,347 Members | 2,091 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,347 IT Pros & Developers. It's quick & easy.

Macro issue...closing current form

xpun
P: 39
hey all

ok i have a macro set to a button(main menu ) on a customer entry form.

Expand|Select|Wrap|Line Numbers
  1. close
  2. close
  3. openform
the problem is when the button(main menu) is clicked while the customer entry form is in edit mode (with the little pencil in the left hand corner) I get a “field cannot be null error…” which prevents the macro from running.

if i change the macro to this it works,

Expand|Select|Wrap|Line Numbers
  1. runcommand : undo
  2. close
  3. close
  4. openform

However it doesn’t work when the form is not in edit mode. An “undo is not available error…” message pops up.

is there any way to set some sort of conditional to fix this. Or suppress the error msg ???

any help is greatly appreciated
ACCESS 2003
Jul 26 '07 #1
Share this Question
Share on Google+
4 Replies


P: 19
hey all

ok i have a macro set to a button(main menu ) on a customer entry form.

Expand|Select|Wrap|Line Numbers
  1. close
  2. close
  3. openform
the problem is when the button(main menu) is clicked while the customer entry form is in edit mode (with the little pencil in the left hand corner) I get a “field cannot be null error…” which prevents the macro from running.

if i change the macro to this it works,

Expand|Select|Wrap|Line Numbers
  1. runcommand : undo
  2. close
  3. close
  4. openform

However it doesn’t work when the form is not in edit mode. An “undo is not available error…” message pops up.

is there any way to set some sort of conditional to fix this. Or suppress the error msg ???

any help is greatly appreciated
ACCESS 2003
macro action>setwarnings, no
Jul 26 '07 #2

xpun
P: 39
macro action>setwarnings, no
nope undo error pops up and the macro is stopped...
Jul 26 '07 #3

xpun
P: 39
phew i finaly gave up on the macro and did it with vb..

I dont think the problem can be fixed in a macro.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command21_Click()
  2. If Me.Dirty = True Then
  3. RunCommand acCmdUndo
  4. DoCmd.Close acForm, "customer entry"
  5. DoCmd.OpenForm ("main")
  6. Else
  7. DoCmd.Close acForm, "customer entry"
  8. DoCmd.OpenForm ("main")
  9. End If
  10. End Sub
  11.  
Jul 26 '07 #4

missinglinq
Expert 2.5K+
P: 3,532
Macros are very limited in what they can do. That's the reason that, with the exceptions of the Autoexec and AutoKeys macros, very few developers use them. They also have no provision for error handling, another huge handicap!

Linq ;0)>
Jul 26 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.