I have tested the modified version and it works fine.

I suggest you rename the function in fnSQLADQuery (because it uses SQL syntax).
I am going to start a new thread for fnLDAPADQuery. The goal is the same than your function but I use LDAP syntax for the search filter.
_________________________
Christophe