That doesn't work in Access, it gives a compile error.
And, running it in excel only affects the excel environment. Access continues to malfunction.
Main Topics
Browse All TopicsI use the following code to launch Access from Excel.
Lpath = "c:\myDB.mdb"
Set AccApp = CreateObject("Access.Appli
AccApp.OpenCurrentDatabase
AccApp.docmd.setwarnings True '<==== THIS DOES NOT WORK EITHER
AccApp.Visible = True
AccApp.Application.Run "startupFromExcel" ' call a procedure named "startupFromExcel".
Accapp.DoCmd.SetWarnings True '<===THIS DOES NOT WORK EITHER
In most respects the resulting Access instance works just as if it was launched from a normal desktop icon.
I can make typical development modifications, like changing a form or a query.
The only problem is that the Access instance acts as if I am running under docmd.setwarnings False.
Every time I close a query, it is saved without the "do you want to save changes" warning.
Does anybody have any suggestions of how to rectify this automatically.
For instance, I tried putting the following code into my Excel and Access modules, BUT THEY DO NOT WORK I still do not get warning messages.
sub startupFromExcel()
docmd.setwarnings true 'DOES NOT WORK
.......
end sub
Even if I close Access, then reopen it manually, the docmd.setwarnings False persists.
The only way to rectify things is to close Access, then use task manager to kill all instances of Access, then reopen Access.
This is very annoying, because it causes me to accidentally make changes to things without realizing it.
I considered having my excel macro automatically kill every existing Access process, but that will not help much, and it strikes me as a little dangerous.
Hope someone can come up with an answer.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
"put it where I need it" seems a little vague since I have already put it various places that don't work.
But I tried a few other places with no success.
If you have any more ideas, you might use the attached demo to see if your ideas work.
Simply put db1test.xls and db1.mdb into c:\. Then open the excel file and push the button.
I found a solution with the help of another forum.
Private Sub CommandButton1_Click()
lPath = "c:\db1.mdb"
again:
' Eventually, we can delete this code
' Depending on how many things go wrong, there can be left over
' processes even when all databases have been closed.
' just to keep things clean while testing, we kill these leftover msaccess instances
'
On Error Resume Next
Set accapp = GetObject(, "access.application")
If Err = 0 Then
accapp.Quit
Set accapp = Nothing
GoTo again
End If
On Error GoTo 0
' the above code can be deleted.
Set accapp = CreateObject("Access.Appli
accapp.OpenCurrentDatabase
accapp.Visible = True ' to avoid run time error 2455
accapp.usercontrol = True ' setting usercontrol must come after setting visible
accapp.Application.Run "startupFromExcel" ' call a procedure named "startupFromExcel".
MsgBox "access now works"
End Sub
Business Accounts
Answer for Membership
by: newbiealPosted on 2009-04-21 at 17:06:40ID: 24200459
Have you tried, Application.DisplayAlerts = True?
.com/code/ 1130/turn- off-warnin g- messages -in-ms-off ice-applic ations/
Here is more info:
http://www.developerfusion
Hope this helps.