My first post here. I have been using this website for a long time to learn VBA and it has helped me a lot! I am having a problem that I have been unable to find a useful post for and I need some help. I have a macro that is hitting a Remedy database using the ODBC driver and works well on my machine. However, when I try to send this Excel file to another user at a different work station, any attempt to run the macro results in a General ODBC Error at the '.Refresh BackgroundQuery:=False' line. I hope I have used the 'Code' button properly so you can view the code. Any help will be greatly appreciated. Thanks!
Code:
StartDate = InputBox("Please enter the start date")
EndDate = InputBox("Please enter the end date")
With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _
"ODBC;DSN=Remedy;ARServer=server.blah.blah;UID=xxx;PWD=xxx;ARAuthentication=;ARUseUnderscores=1;ARNameReplace" _
), Array("=1;SERVER=NotTheServer")), Destination:=Range("A1"))
.CommandText = Array( _
"SELECT ""MNT:Maintenance"".RequestID, ""MNT:Maintenance"".Region, ""MNT:Maintenance"".System, ""MNT:Maintenance"".""Device Alias+"", ""MNT:Maintenance"".PlannedStartDate, ""MNT:Maintenance"".""HCF Fibernode""" & Chr(13) & "" & Chr(10) & "FROM """ _
, _
"MNT:Maintenance"" ""MNT:Maintenance""" & Chr(13) & "" & Chr(10) & "WHERE (""MNT:Maintenance"".PlannedStartDate>{ts '" & Format(StartDate, "yyyy-mm-dd hh:mm:ss") & "'} And ""MNT:Maintenance"".PlannedStartDate<{ts '" & Format(EndDate, "yyyy-mm-dd hh:mm:ss") & "'})" & Chr(13) & "" & Chr(10) & "ORDER BY ""MNT:Maintenance""." _
, "Region, ""MNT:Maintenance"".System")
.Refresh BackgroundQuery:=False
End With