Is there an easy way when running this macro to prompt the user to path to the database of interest? The query will remain the same for every case; only the database that it's pulling information from will change. I've been opening the VB editor and manually changing the location name, but it would be nice to be able to have a message box pop up asking for the location. The things that I change manually are bold and italicized below. This is just a part of a macro that works with the data imported.
Thanks!
With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;DSN=Pittman_3_3;DBQ=I:\Sharea\Brown\Pittman_3_3.mdb;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;" _
, Destination:=Range("A1"))
.CommandText = Array( _
"SELECT AC_PROPERTY.APINUM, AC_PROPERTY.PROPNAME, AC_PROPERTY.PUDNAME, AC_PROPERTY.LOC_SEC, AC_PROPERTY.LOC_TN, AC_PROPERTY.LOC_RN, AC_PROPERTY.OPERNAME, AC_PROPERTY.RESERVOIR, AC_ONELINE.M25 AS 'Gas C" _
, _
"UM', AC_ONELINE.M22 AS 'Gas EUR', AC_ONELINE.M23 AS 'Oil ', AC_ONELINE.M21 AS 'Oil EUR'" & Chr(13) & "" & Chr(10) & "FROM `I:\Sharea\Brown\Pittman_3_3.mdb`.AC_ONELINE AC_ONELINE, `I:\Sharea\Brown\Pittman_3_3.mdb`.AC_PROPERTY AC_P" _
, "ROPERTY" & Chr(13) & "" & Chr(10) & "WHERE AC_PROPERTY.PROPNUM = AC_ONELINE.PROPNUM")
.Name = "Query for Pittman_3_3.mdb"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With