Results 1 to 3 of 3
  1. #1
    theosgood is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Location
    Denver, CO
    Posts
    30

    DLookUp DataType Mismatch Error


    Using Access 2007

    Getting a datatype mismatch error when using dlookup in a procedure but everything looks correct. Second set of eyes please.

    Table = BuyerDepartment
    Fields = Dept Text(4), Dept_CD Text(3), Analyst_Tables_Path Text(255)

    Values = Dept - 912A, Dept_CD - 912, Analyst_Tables_Path = \\tsavm45\ATIDev$\Business Analysis\DataSource\AnalystTables-Footwear.mdb

    <code>
    Dim DeptList As ADODB.Recordset ' Create recordset variable for Buyer departments
    Dim strPathA As String ' The path to Analyst databases. This is assigned in loop based on dept.
    Dim DeptStr As String ' The 4 char Dept number including A, B, C
    Dim DeptCDStr As String ' The 3 char Dept number

    DeptList.Open "Select Dept, Dept_CD from BuyerDepartment order by Dept asc", CurrentProject.Connection, adOpenForwardOnly

    DeptList.MoveFirst
    dbcount = 0

    Do While Not DeptList.EOF

    'Assign Dept value
    DeptStr = DeptList.Fields("Dept").Value
    DeptCDStr = DeptList.Fields("Dept_CD").Value

    'Get Analyst
    strPathA = DLookup("Analyst_Tables_Path", "BuyerDepartment", "Dept =" & DeptStr)

    <code>

    strPathA giving me a datatype mismatch error but I don't see the problem.

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    If "Dept" is a text field, you are missing text qualifiers around its value.
    See this: http://support.microsoft.com/kb/208786 (see section on Specifying Textual Criteria)
    and/or
    http://allenbrowne.com/casu-07.html

  3. #3
    theosgood is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Location
    Denver, CO
    Posts
    30
    Thanks, your suggestion worked using strPathA = DLookup("Analyst_Tables_Path", "BuyerDepartment", "Dept = '" & DeptStr & "' ")

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 08-22-2012, 07:32 AM
  2. VBA DLookup - Type Mismatch
    By hannuk in forum Access
    Replies: 2
    Last Post: 01-03-2012, 06:33 AM
  3. Newbie. DLookup gives type mismatch error.
    By graffiti in forum Programming
    Replies: 4
    Last Post: 12-13-2011, 05:22 AM
  4. datatype mismatch in criteria expression
    By CyberSkillsz in forum Access
    Replies: 1
    Last Post: 06-14-2011, 10:56 AM
  5. confusing datatype error issue
    By TheShabz in forum Queries
    Replies: 5
    Last Post: 10-11-2010, 05:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums