Transfer AD recordset to a table

ppataki

Registered User.
Local time
Today, 08:40
Joined
Sep 5, 2008
Messages
267
Dear All,

I have the below code that extracts user list from AD and displays it in the Immediate Window
My problem is that I am struggling with putting the data in a table instead of displaying it in the Immediate window

Could you please advise?
Many thanks in advance

Code:
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 10
objCommand.Properties("Size Limit") = 100

objCommand.CommandText = "<LDAP://EAME/OU=Users,OU=usr,OU=objects,DC=EAME,DC=SYNGENTA,DC=ORG>;(&(objectClass=user)(c=hu));name;subtree"
Set objRecordSet = objCommand.Execute

While Not objRecordSet.EOF
Debug.Print objRecordSet.Fields("Name")
objRecordSet.MoveNext
Wend
objConnection.Close
 
Code:
....
While Not objRecordSet.EOF
CurrentDB.Execute "Insert Into [B]MyTable[/B] ([B]Fieldname[/B]) Values ( '" & objRecordset.Fields("Name") & "')", dbFailOnError
objRecordSet.MoveNext
Wend
...

is one way if the table is a linkedtable or local table

JR
 
Thank you very much, it works fine!!!
:)
 

Users who are viewing this thread

Back
Top Bottom