-
October 30th, 2009, 01:28 PM
#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
-
October 30th, 2009, 08:08 PM
#2
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
-
November 2nd, 2009, 09:08 AM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|