CharlieT302
Instructor
Hi All,
The code below (with help from some great people here)successfully builds a table by pulling Active Directory fields.
I would really love to be able to incorporate in into an Access query. I can then use the query as a data source for combo boxes, etc. Can this be done?
Also, to change the code to a Make Table equivalent, would I change the "Insert Into" line to a Select statement? And what would be the syntax?
How can I accomplish these two things?
Code:
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Open "Provider=ADsDSOObject;"
objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"<LDAP://dc=ad,dc=Oggwin,dc=org>;(objectcategory=user);sn,givenname;subtree"
Set objRecordset = objCommand.Execute
DoCmd.RunSQL "INSERT INTO tbl_Sample_staff (givenname, Sn)VALUES (""" & Replace(NZ(objRecordset!givenname,""), """", """""") & _
""", """ & Replace(NZ(objRecordset!sn,""), """", """""") & """)"
While Not objRecordset.EOF
objRecordset.MoveNext
Wend
objConnection.Close
The code below (with help from some great people here)successfully builds a table by pulling Active Directory fields.
I would really love to be able to incorporate in into an Access query. I can then use the query as a data source for combo boxes, etc. Can this be done?
Also, to change the code to a Make Table equivalent, would I change the "Insert Into" line to a Select statement? And what would be the syntax?
How can I accomplish these two things?
Code:
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Open "Provider=ADsDSOObject;"
objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"<LDAP://dc=ad,dc=Oggwin,dc=org>;(objectcategory=user);sn,givenname;subtree"
Set objRecordset = objCommand.Execute
DoCmd.RunSQL "INSERT INTO tbl_Sample_staff (givenname, Sn)VALUES (""" & Replace(NZ(objRecordset!givenname,""), """", """""") & _
""", """ & Replace(NZ(objRecordset!sn,""), """", """""") & """)"
While Not objRecordset.EOF
objRecordset.MoveNext
Wend
objConnection.Close