Macros in 2010

speakers_86

Registered User.
Local time
Yesterday, 19:44
Joined
May 17, 2007
Messages
1,919
Are they different than previoius versions? Even in mdb? I ask this because I was recently troubleshooting what I thought was corruption, though it turned out not to be. I recreated an AutoExec in 2010, and it worked fine. When I moved to a different computer, it failed. I opened it in design view, and there were lines added with text that literally said something about it being created in a newer version of access. What seemed to be the most messed up is an if statement that tested if the db is trusted. Instead of my if statement, it was replaced with something like : [LocalVars]. and some other stuff I certainly didn't type.

I've recreated the macro in a blank db in 2010, and it's attached. Could someone in an older Access version take a look.

If this is the case could someone possibly fix the macro inside their older version of Access for me?

Here is the pseudo code for the macro.
Code:
if currentproject.istrusted=false then
   openform Aph_frmEnableContent
else
   run code LoadAppRibbonInGui
   openform Aph_frmSettingsLocal ,,,,Hidden
end if
 
Hi,

I think you might have left out one important detail.
You said:

When I moved to a different computer, it failed.

You didn't mention what Access version is on that other computer.
Is it also running Access 2010 or does it have an earlier version of Access like 2007 for example?

I'm going to assume for the moment that it has an earlier version of Access. In that case I can see what the problem is.

Access 2010 introduced the concept of If/Else/Else If constructs into macros. While it is true that you could give an If-type of condition to a macro in the Conditions column in earlier versions, you could not do an Else or Else If type of logic in the macros. In order to achieve that type of functionality in earlier versions, you needed to have a new condition each time or repeat the previous one. In a sense what this meant was that every macro line in previous versions that had a condition was performing an If and then ending with an End If.

Does that make sense?

So in your macro that you created in 2010, you added an Else statement. Naturally, creating conditional logic is way easier now in Access 2010 macros but since you want this database to also be used in earlier versions you absolutely must stay away from using any Else or Else If lines as you develop. You will need to provide a different If expression if you want to do something else.

I've attached your database again here and you'll see it now runs just fine in both Access 2007 and Access 2010. Take a look at the minor change I made.

Hope that helps,

--------------------
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
----------
 

Attachments

Okay, thanks. Why the elipses (...) for the condition in the last statement though?
 
Hi,

In versions of Access pre-2010, if you wanted to run a series of actions on the basis of the outcome of a condition, you wrote the expression on the first line in the Condition column. To have the same expression ran against subsequent actions, you had to repeat the entire expression again or just use the handy (...) three ellipsis trick to just repeat it without retyping everything again.

If it helps, think of it this way. Adding an (...) means that action line was going to be inside the If/End If instead of outside.

Does that help explain?

--------------------
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