PDA

View Full Version : Solved: Change in Path to Server - Query Macros Affected



ScriptHam
10-18-2012, 03:51 AM
Hi

The company that I work for has changed from file servers at our HQ to a local file server in our own small suite of offices. As a result the file paths have changed. This causes some of my automation to fail.

My Access databases worked OK except that all linked tbls had to be relinked. I don't understand why but...

My Excel sheets which query my databases now report errors although if I change a few database records and then requery the result is as expected.

As one sheet loads I get the usual macro warning and I enable the macros.
Then there is an error warning:
Run time error 1004
Applicatiom-defined or object-defined error
(Buttons) Continue End Debug Help

On selecting debug the following line of code is highlighted.


Selection.QueryTable.refresh BackgroundQuery:=False

The entire module is


Sub Auto_Open()
'
' Auto_Open Macro
' Macro recorded 04/02/2010 by parka
'

'
Sheets("shtMsQuery").Select
Selection.QueryTable.refresh BackgroundQuery:=False
Sheets("shtSpec").Select
End Sub

Can anyone help me with this please.
Thanks.
ScriptHam

snb
10-18-2012, 05:16 AM
Sub Auto_Open()
Sheets("shtMsQuery").QueryTables(1).refresh False
End Sub

ScriptHam
10-18-2012, 08:21 AM
Hi

Thanks SNB.
This works.
ScriptHam