Encapsulate embedded Marco with IF THEN..

SmallTime

Registered User.
Local time
Today, 12:24
Joined
Mar 24, 2011
Messages
246
I’ve recently started using access 2010 and am busy updating my A2K databases. Just started getting to grips with the beast (table level calculated fields are great). However, these new embedded macros seem to have a mind of their own.

I’ve used the wizard to create a delete record button with an embedded macro and it looks good as it takes care of all possible scenarios.

Now, I’ve been trying to encapsulate the 3 or so if then statements of the macro (exluding the error handling of course) in an if msgbox(…….)=vbYes (or rather = 6) but no matter what I try I can’t seem to move the end if to wrap the other If then statements.

Any ideas?
 
One thing you can do is move the messagebox out of it to make it easier to see what you are doing.

e.g.

Code:
dim response
 
response = msgbox "yes or no",blah blah (I forget the actual arguements!)
 
if response = vbYes then
   'yes code
else
   'no code
end if
 
Thanks for the reply

Is this for an embedded macro? (using access 2010) still can't see how to move the End IF to wrap everything else.

Excuse my seeming ignorance but I've only just started playing with the new macro type
 
Ahhh just spotted your "Attention: Any advice"

Thanks anyway
 
Ahhh just spotted your "Attention: Any advice"

Thanks anyway

Yeah, sorry, was talking in VBA rather than 2010 macros.

I can just about get access to Office 2007 now, but still not 2010 :p
 
I'm giving up on the new marco for now, it's just taking too long and not that easy to read, but that might be just me not being used to the interface.

Also seems a little limited in scope and usage, I would have expected a lot more from the guys at Ms before rolling out something so fundamental. Anyway the other new functions make up of it, but lots of annoying downsides too.

I too would have stuck with an older version (loved A2K) but I suspect with 64 bit OS and more users switching to office 2010 the need to rebuild is inevitable.

Take care
SmallTime
 
Ah,

I develop databases for use within my business and I know that other than about 4 workstations with Office 2007 they all have 2003.

And given that there's a few hundred workstations in this building alone I can't see them paying for 2010 licenses for all of them until they have an unavoidable reason to do so.
 
Hi,

If you select an If block in the 2010 macro designer, you can then click the Up or Down arrow buttons on the right side to move the whole block up/down or inside a different block of actions. You can also use drag and drop with your mouse too.

Does that work for you?

If not, could you perhaps post a screenshot of your macro design window for me to look at?

Thanks,

--------------------
Jeff Conrad - Access Junkie - MVP Alumnus
SDET II - Access Test Team - Microsoft Corporation

Author - Microsoft Access 2010 Inside Out
Co-author - Microsoft Office Access 2007 Inside Out
Access 2007/2010 Info: http://www.AccessJunkie.com

----------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.mspx
----------
 
Ah yes, you wrapped the problem in a nutshell. The whole block moves.

What I want to do is move the End IF part ONLY so I can have lots of lovely nested if then's

Thanks for the pointers

Take Care
SmallTime
 
Will post the screen shot in a while, just have to pop next door and help my dear old neighbour with an email.
 
Ah ha,

It works just as suggested.

I did the very same thing yesterday and it wouldn't play. Later, when trying to make a query, I discovered I'd some corruption creep into my working project and imported everything into fresh database but didn't try playing with the macros after that.

Now it all makes sense again, I think I'll try playing around with the macros just to get my feet wet and introduce myself to the interface.

Many thanks
SmallTime
 
You're welcome, glad to help.

I hope you continue exploring the new macro interface and the improvements that were made in this space for 2010. I realize not everyone wants to use macros, but they are much improved in 2010.

Also, if you want to create new data macros attached to table events or named data macros in 2010, you have to use the new macro design surface. Data macros are a very powerful feature add for 2010 so it's a really good idea to become familiar with the new macro designer, even if you use VBA for everything else.

Good luck with your projects.

--------------------
Jeff Conrad - Access Junkie - MVP Alumnus
SDET II - Access Test Team - Microsoft Corporation

Author - Microsoft Access 2010 Inside Out
Co-author - Microsoft Office Access 2007 Inside Out
Access 2007/2010 Info: http://www.AccessJunkie.com

----------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.mspx
----------
 

Users who are viewing this thread

Back
Top Bottom