Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stop dialog boxes when an Update query is run 2

Status
Not open for further replies.

DawsonUK

Programmer
Nov 22, 2002
38
0
0
GB
Hi,

Is there a way to stop the dialog boxes appearing when a query is run?

What I'm trying to achieve is to run a query which puts all its results in a table, which is then used for a mail merge. The problem is that I get 3 popup dialog boxes asking me to confirm this action.

Is there a way to stop them appearing?

Thanks in advance to any help or advice,
David Dawson
 
Excellent, you've saved my life!

A well deserved Star for you my quick replying fellow!

 
But...make sure you've got an exit label section that will execute regardless or error. If you turn set warnings off it's a persistent setting.


[tt]

Sub YourSub(strQName As String)
On Error GoTo Exit_YourSub

DoCmd.SetWarnings False
DoCmd.OpenQuery strQName

Exit_YourSub:
DoCmd.SetWarnings True
Exit Sub

End Sub
[/tt]
 
Hi, thanks for the reply. I'd already done that, heres the code I'm using incase anyone else is interested...

'Turn off warnings
DoCmd.SetWarnings False
'Run Query
DoCmd.OpenQuery "Mail Merge - Selected Student - Main Menu"
'Turn on warnings again
DoCmd.SetWarnings True

'Mail merge selected student
Dim docname As String
docname = "H:\templates\preg\singlestudent-mainmenu.doc"
Dim objApp As Object
Set objApp = CreateObject("Word.Application")
objApp.Visible = True
objApp.Documents.Open docname

When the query is run, it clears a table contents, and inserts the query results. In this example, details of a student that's being selected from a drop down menu. Then a word document is loaded from the Users Home drive (H: drive), where the source is that table that has just been filled with data from the query.

A bit over the top maybe, but it works, and works well.

Thanks,
David
 
David,

It's best to turn warnings on again in an exit label with the OnError Goto. Otherwise if something bombs in OpenQuery (and no procedure is immune to weird errors) the warnings will be toggle off until reset in code again.

Regards,

Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top