If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > dlookup in excel vba....

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-28-06, 03:00
sal21 sal21 is online now
Registered User
 
Join Date: Oct 2004
Posts: 61
dlookup in excel vba....

Assuming i have this mdb:
http://www.mytempdir.com/548579

and a sheet TEST where into A2 is:OI14006 is possible to use the table into mdb to return in B2: GERVASIO CRISTOFARO
IN effect i would want to use all in vba for excel.

Sub test()
Dim cn As Object, rs As Object
Dim myReturn As Long
Const dbfullname As String = "c:\DATA\user.mdb"

Set cn = CreateObject("ADODB.Connection")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" _
& dbfullname & ";" 'Create DB connection

Set rs = CreateObject("ADODB.Recordset")
With rs

''''
peraps here the code for matching?

''''
If Not .EOF Then Let myReturn = .fields(0)
.Close: Set rs = Nothing
End With

cn.Close: Set cn = Nothing

End Sub

Last edited by sal21; 03-28-06 at 03:06.
Reply With Quote
  #2 (permalink)  
Old 03-28-06, 13:02
shades shades is offline
Registered User
 
Join Date: Oct 2003
Posts: 1,091
Cross-post JMT Forums.

And cross-post Access Programmers Forum
__________________
old, slow, and confused
but at least I'm inconsistent!

Rich
(retired Excel 2003 user, 3/28/2008)

How to ask a question on forums
Reply With Quote
  #3 (permalink)  
Old 03-29-06, 00:37
Fazza Fazza is offline
Registered User
 
Join Date: Feb 2006
Posts: 113
sal,

I haven't looked at the database sample.

However, if you have the connection and CommandText / SQL OK, what is the problem exactly?

cheers,
Fazza
Reply With Quote
  #4 (permalink)  
Old 03-30-06, 09:55
shades shades is offline
Registered User
 
Join Date: Oct 2003
Posts: 1,091
Check the solution provided at JMT Forums (link in my post above)
__________________
old, slow, and confused
but at least I'm inconsistent!

Rich
(retired Excel 2003 user, 3/28/2008)

How to ask a question on forums
Reply With Quote
  #5 (permalink)  
Old 03-30-06, 18:39
Fazza Fazza is offline
Registered User
 
Join Date: Feb 2006
Posts: 113
Thanks shades. I'm not a registered user at the other site - hence can not access the solution posted.

Would appreciate if you could post the gist of the answer from the other forum.

If not, no worries. I won't lose any sleep over it.

regards,
Fazza
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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