Query on update

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What is the code on an event procedure to have it run an
update query without showing the user anything?

For example, I want certain fields to update after they
have updated a subform.
 
If you mean the system messages that warn of 'xx records to be
updated/added/deleted' when you use an action query.
.... those messages can be suppressed/enabled with
DoCmd.SetWarnings False
DoCmd.OpenQuery someActionQuery
DoCmd.SetWarnings True

There are some other options
e.g. the Execute method of the Database (or Connection) object can be used
sql$ = " DELETE * FROM tblFred WHERE [Obsolete] = True"
CurrentDb.Execute sql$

but the simplest to use if you have the queries already built is the
SetWarnings route.

CD
 
Chadlon said:
If you mean the system messages that warn of 'xx records to be
updated/added/deleted' when you use an action query.
... those messages can be suppressed/enabled with
DoCmd.SetWarnings False
DoCmd.OpenQuery someActionQuery
DoCmd.SetWarnings True

There are some other options
e.g. the Execute method of the Database (or Connection) object can be used
sql$ = " DELETE * FROM tblFred WHERE [Obsolete] = True"
CurrentDb.Execute sql$

but the simplest to use if you have the queries already built is the
SetWarnings route.

Execute is perfectly capable of executing a stored query.
 
Rick,

Am I missing your point?
Do you mean Execute on a QueryDef object?
Is that a shorter route for the OP to take, given his implied start point of
DoCmd.OpenQuery someActionQuery

CD

Rick Brandt said:
Chadlon said:
If you mean the system messages that warn of 'xx records to be
updated/added/deleted' when you use an action query.
... those messages can be suppressed/enabled with
DoCmd.SetWarnings False
DoCmd.OpenQuery someActionQuery
DoCmd.SetWarnings True

There are some other options
e.g. the Execute method of the Database (or Connection) object can be used
sql$ = " DELETE * FROM tblFred WHERE [Obsolete] = True"
CurrentDb.Execute sql$

but the simplest to use if you have the queries already built is the
SetWarnings route.

Execute is perfectly capable of executing a stored query.
 
Chadlon said:
Rick,

Am I missing your point?
Do you mean Execute on a QueryDef object?
Is that a shorter route for the OP to take, given his implied start point of
DoCmd.OpenQuery someActionQuery

CurrentDB.Execute "NameOfQuery", dbFailOnError

Seems short enough to me : )
(and no confirmation prompts)
 
Back
Top