PDA

View Full Version : Solved: Silently run Update query?



CreganTur
03-20-2008, 11:25 AM
I know this is probably an unusual problem, but I can't find an answer.

I've got a form where Users enter some account information into the databse. One of the issues is that the account numbers they are entering have 4 zeros at the start of the account number (which aren't needed for anything...ever; they are 18 digits long with the useless zeros). So I created a simple Update Query of:


RIGHT([AcctNmbr],14)

This removes the useless zeros and truncates the account number perfectly. I'm using the following VBA to kick off the Query when the form is closed:

Private Sub Form_Close()
DoCmd.OpenQuery "qryUpdateAcctNmbr"
End Sub

Now, when a User closes the form the usual warning windows popup, asking the user if they really want to update all of these records, etc. I know that these messages will freak out some of my elderly users, so is there any way to run the update query without those messages appearing?

Trevor
03-20-2008, 11:54 AM
before your docmd.open query
use:

set warnings false

then after the query turn them back on with, yep you guessed it.

set warning true

akn112
03-20-2008, 12:00 PM
docmd.setwarnings false
docmd.openquery...
docmd.setwarnings true

CreganTur
03-20-2008, 12:19 PM
before your docmd.open query
use:

set warnings false

then after the query turn them back on with, yep you guessed it.

set warning true


That doesn't work, but it did point me to the right answer, so thanks Trevor.

To get this to work you have to use:

DoCmd.SetWarnings False
DoCmd.OpenQuery "qryUpdateAcctNmbr"
DoCmd.SetWarnings True

NinjaEdit: thanks akn112- you squeeked in right before me ;)