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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I bypass the runtime error message? 1

Status
Not open for further replies.

benderulz

IS-IT--Management
Nov 2, 2010
43
US
I'm using an hta to control Access macros from multiple databases, but if a user cancels a query input they receive a runtime error message asking them to debug. I do not want my users to have that option. Is there a way to suppress this message? I have included my script below.

<SCRIPT LANGUAGE=vbscript>
Sub TimeStudy
Const DBPath = "db path here"
If TS.Value = 2 Then
MacroName = "InSS"
Set AccessApp = GetObjectDBPath, "Access.Application")
AccessApp.Visible = False
AccessApp.DoCmd.RunMacro MacroName
AccessApp.Quit
End If
If TS.Value = 3 Then
MacroName = "OBSS"
Set AccessApp = GetObject(DBPath, "Access.Application")
AccessApp.Visible = False
AccessApp.DoCmd.RunMacro MacroName
AccessApp.Quit
End If
End Sub

</SCRIPT>

Thanks,
Rich
 
You may try this:
...
AccessApp.DoCmd.SetWarnings False
AccessApp.DoCmd.RunMacro MacroName
AccessApp.DoCmd.SetWarnings True
...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
The code above would stop notifications from Access, but the error I'm trying to suppress is from the HTA. I think it will require an "on error" condition, but I'm sure not sure how to script it. Thank you for the effort.
 
Like this ?
Sub TimeStudy
[!]On Error Resume Next[/!]
Const DBPath = "db path here"
...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
That worked perfectly. I was trying to put the condition where the code was failing. for example:

AccessApp.Visible = False
AccessApp.DoCmd.RunMacro MacroName
On Error Resume Next
AccessApp.Quit

Thank you for the help! I've just started scripting (as I'm sure you can tell) and still have alot to learn.

Thanks PHV!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top