Link to home
Start Free TrialLog in
Avatar of MonkeyPie
MonkeyPieFlag for Australia

asked on

Access 2010 - using docmd.setwarnings False across various backends

My client has a separate backend database for each state - all with exactly the same design.

My .accdb frontend has functionality so users can open and close these state backends, with only one state 'open' at a time.   The code links to whichever state BE the user has chosen.

 In addition, the user can 'archive' data from the current state  BE into another empty BE.

The archive database is opened by:
Set ArchiveDB = DBEngine.OpenDatabase(Me.txtArchiveDB)

and the BE to delete archived records is currently linked backend.

My issue is with warnings.  I use docmd.setwarnings FALSE every time a new state BE is opened/linked and this works well.  But the user is getting warnings about updating  - I am guessing from the archive db.

So, how exactly does setting warnings off work where there are several backends, and how do I set warnings via VBA when I use the

Set ArchiveDB = DBEngine.OpenDatabase(Me.txtArchiveDB)

code?
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Instead of using DoCmd.RunSQL or DoCmd.OpenQuery for your action queries, use:

CurrentDB.Execute "DELETE * FROM YourTable WHERE ...", dbFailOnError

Open in new window

The CurrentDB.Execute syntax for UPDATE, DELETE etc action queries will avoid the warning messages you are describing, and the dbFailOnError will provide more meaningful error messages if there is something intrinsically wrong with the SQL statement itself.
Avatar of MonkeyPie

ASKER

Thank you mbizup, That is good info.  But I still want to know how setting warnings to off works when you are using several backends.  Does the warning flag apply to the front end regardless of what the 'confirm record changes option' is set for each individual backend?

Or, each time the user closes one state db and opens another (within the one session) does the warning setting get set to the current backend setting?
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you.

So that explains why my users get unexpected 'You are about to delete xx rows.' messages, even after I have turned OFF warnings.