Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2004
    Posts
    72

    Unanswered: 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 04:06.

  2. #2
    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

  3. #3
    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

  4. #4
    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

  5. #5
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •