Avatar of Paul Burrows
Paul BurrowsFlag for New Zealand asked on

How do I stop macro warnings showing

In Access 2000 I used to enter a line
Set Warnings Off
(or something)

How do I do this in Access 2007

Thanks
Paul
Microsoft Access

Avatar of undefined
Last Comment
Paul Burrows

8/22/2022 - Mon
Missus Miss_Sellaneus

Got the following from http://office.microsoft.com/en-us/access/HP010379431033.aspx

Const cDatabaseToOpen = "C:\<FileToOpen>.mdb"
 
On Error Resume Next
Dim AcApp 
Set AcApp = CreateObject("Access.Application")
If Val(AcApp.Version) >= 11  Then
	AcApp.AutomationSecurity = 1 ' msoAutomationSecurityLow
End If
AcApp.Visible = True
AcApp.OpenCurrentDatabase cDatabaseToOpen 
If AcApp.CurrentProject.FullName <> "" Then 
	AcApp.UserControl = True
Else
	AcApp.Quit
	MsgBox "Failed to open '" & cDatabaseToOpen  & "'."
End If

Open in new window

ASKER
Paul Burrows

This is a little more complicated than I thought

Is there not a macro command I can simple enter?
Emil_Gray

DoCmd.SetWarnings False

'Don't forget to reverse this when you are finished

DoCmd.SetWarnings True

Also, you could convert the Macro to a Module. In database view choose 'Macros' then select your macro without opening it. Then click on File/Save As and in the dropdown choose Module. Then in database view choose 'Modules' and search for 'Converted Macro - Name of your Macro'

I NEVER use Macros.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER
Paul Burrows

Sorry ... Cannot follow this .... All I am able to enter is an "Action" and an "Argument" in the Macro section

How do I enter the "DoCmd.SetWarnings False" part?
Emil_Gray

Here is a db with just a Macro and a Module. The Module is the Macro automatically converted.
Your-Macro.mdb
Emil_Gray

I just noticed you are using Access 2007. However the same commands with a bunch more are available to you with a Macro. I just never did like using them. I much prefer Modules.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
Paul Burrows

I think Access 2007 is the difference .... when setting up the macro I am unable to enter the "SetWarnings" command
Emil_Gray

Which leads me to my point about using vba and modules instead of macros. A function with the commands you require is much easier to write than using a macro especially since Microsoft has once again changed how they work. What commands do you require the macro to run?
ASKER
Paul Burrows

Been reluctant as have had no experience with modules.  Macros have always worked for me in the past with Access 2000

I'm just chaining queries.together to execute one after the other
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Emil_Gray

Use this format. You can put as many DoCmd.OpenQuery statements as you like.
Function myQueries
On Error GoTo Err_myQueries
 
DoCmd.SetWarnings False
 
DoCmd.OpenQuery "name of query"
 
DoCmd.SetWarnings True
 
Exit_myQueries:
Exit Function
 
Err_myQueries:
MsgBox Err.Number, Err.Description
GoTo Exit_myQueries
 
End Function

Open in new window

ASKER CERTIFIED SOLUTION
Emil_Gray

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
Paul Burrows

Thanks very much.  I shall use this Monday when I am at work.  

Looks like I have now been dragged kicking and screaming into the world of visual basic!

Thanks again