View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
monkey harry monkey harry is offline
external usenet poster
 
Posts: 5
Default Lookup in Excel/Access

Thanks, can't get it to work though.

Here is my code. It opens a new access query and will filter it
according to what is used as "ID". This is the part I'm struggling
with as I want it to ask the user to input the ID:

' Open query
With ActiveSheet.QueryTables.Add(Connection:=Array(Arra y( _
"ODBC;DSN=MS Access Database;DBQ=G:\My
Documents\db3.mdb;DefaultDir=G:\My Documents;DriverId=25;FIL=MS
Access;MaxBufferSize=2048;Page" _
), Array("Timeout=5;")), Destination:=Range("F11"))
.CommandText = Array( _
"SELECT `Section 4 list`.ID, `Section 4 list`.FullName,
`Section 4 list`.FlatRoom, `Section 4 list`.HouseName, `Section 4
list`.HouseNumber, `Section 4 list`.StreetName, `Section 4
list`.TownName, `Sec" _
, _
"tion 4 list`.PostCode" & Chr(13) & "" & Chr(10) & "FROM `G:\My
Documents\db3`.`Section 4 list` `Section 4 list`" & Chr(13) & "" &
Chr(10) & "WHERE (`Section 4 list`.ID=1)" _
)
.Name = "Query from MS Access Database"
.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
End Sub