CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2009
    Posts
    1

    Error 13 in debug.print

    I am trying to extract user information from my Active Directory server using ADODB..
    Everything works well except for 1 of the attributes which id UID if am using the following statement:

    dim strUID
    strUID=iff(isnull(adoRecordset.Fields("UID").value),"",adoRecordset.Fields("UID").value)

    At Runtime, as soon as there is a non Null value, I receive the following message:
    Run-tim error '13': Type mismatch..

    I have tried to debug.print but I receive the same error message.

    Help would be greatly apprieciated.

    Robert

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Error 13 in debug.print

    Add this:

    Code:
    Debug.Print  adoRecordset.Fields("UID").value
    
    Debug.Print  adoRecordset.Fields("UID").value
    somewhere and you'll see the problem.

    Check the values BEFORE setting the variable
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Error 13 in debug.print

    Yes, the problem is the iif() function, I guess.
    In an iif always both resulting terms are evaluated. This leads to problems in some case.
    Try to formulate this as an If Then Else statement.
    Using If Then Else does NOT execute the statements of the opposite condition.
    Code:
    If isnull(adoRecordset.Fields("UID").value) Then strUID = "" Else strUID=adoRecordset.Fields("UID").value
    But come to think of it... because of Type Mismatch Error...
    If .Fields("UID").Value is a numeric data type you simply have to convert it to string within the Iif statement:
    Code:
    strUID=iff(isnull(adoRecordset.Fields("UID").value),"",CStr(adoRecordset.Fields("UID").value))

Tags for this Thread

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured