LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Lookup In Excel from Access Database

I need help on the following code, since I am very new at this, I am lost.

I am using a excel spreadsheet. In A1 is criteria "A1[AS400 ID]"
A2 needs to be the result. I have used lookup in Access VBA code but now
need to translate to Excel VBA code. So I may be totally on the wrong track.


Any help would be appreciated



Sub ADOImportFromAccessTable()

Dim cn As ADODB.Connection, rs As ADODB.Recordset, intColIndex As Integer
Dim TargetRange As Range

Set TargetRange = TargetRange.Cells(2, 1)


' open the database
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
[\\Dtcnas-ilsp002\mandatory\Analysts - Working
Files\Carol\Demo\Tradelimit.mdb] & ";"

Set rs = New ADODB.Recordset
With rs
' open the recordset
.Open [End of year incentive], cn, adOpenStatic, adLockOptimistic,
adCmdTable


'Criteria Range A1[AS400 ID]
'I NEED TO DO A LOOKUP
'A2 = DLookup("[V05 GOVT]", "End of year incentive", "[AS400 #] = " _
& Forms!Form![AS400 ID])

'Copy range to A2
Range("A2").CopyFromRecordset rs


End With
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub
--
ca1358
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Update Excel Database via Access Main Database with a script Finnbar New Users to Excel 2 November 3rd 08 07:24 PM
Excel Database or Access?? Centrol Excel Worksheet Functions 1 October 27th 08 09:56 AM
Do I need Excel or Access for my database needs? Emily Excel Discussion (Misc queries) 3 February 21st 08 05:04 PM
Lookup information in Access Database John Excel Discussion (Misc queries) 3 April 27th 07 03:35 PM
Code to 'lookup' value in Access database maacmaac Excel Discussion (Misc queries) 0 September 16th 05 02:52 AM


All times are GMT +1. The time now is 10:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"