DoCmd.OpenQuery

  • Thread starter Thread starter Michael Kintner
  • Start date Start date
M

Michael Kintner

How can I use DoCmd.OpenQuery and not have it prompt that it is performing a
append or delete. I would like it to perform the operation without giving
me the warnings and just do it.

Example in use within Access VB:
DoCmd.OpenQuery "qry-append-BuildMonthlyUsage"
DoCmd.OpenReport "rpt-ShowMonthlyUsage", acViewPreview

Or is there another method that I should be using?

Thank you in advance for your help,
Michael Kintner
 
How can I use DoCmd.OpenQuery and not have it prompt that it is performing a
append or delete. I would like it to perform the operation without giving
me the warnings and just do it.

Example in use within Access VB:
DoCmd.OpenQuery "qry-append-BuildMonthlyUsage"
DoCmd.OpenReport "rpt-ShowMonthlyUsage", acViewPreview

Or is there another method that I should be using?

Thank you in advance for your help,
Michael Kintner

DoCmd.SetWarnings False
DoCmd.OpenQuery "qry-append-BuildMonthlyUsage"
DoCmd.SetWarnings True
DoCmd.OpenReport "rpt-ShowMonthlyUsage", acViewPreview


An alternative method can be used without the need to set warnings.

CurrentDb.Execute "qry-append-BuildMonthlyUsage", dbFailOnError
DoCmd.OpenReport "rpt-ShowMonthlyUsage", acViewPreview
 
How can I use DoCmd.OpenQuery and not have it prompt that it is performing a
append or delete. I would like it to perform the operation without giving
me the warnings and just do it.

Example in use within Access VB:
DoCmd.OpenQuery "qry-append-BuildMonthlyUsage"
DoCmd.OpenReport "rpt-ShowMonthlyUsage", acViewPreview

Or is there another method that I should be using?

Thank you in advance for your help,
Michael Kintner

Try this:

DoCmd.SetWarnings False
' Your code goes here
DoCmd.SetWarnings True
 
You can use two ways. The first is with the DoCmd command and the second one
is to execute the query as follows:

currentdb.execute "your queryname here", dbfailonerror

The second method is:

DoCmd.SetWarnings False
docmd.openquery
docmd.set warnings true

You can see the drawback from this one. If the query fails your warnings
will not be turned on again. So in your errorhandling always place the set
warnings true option so they are set back again.

Most of the people prefer the first option of executing for that reason...

hth
 
Back
Top