CharlieT302
Instructor
Hi All,
The code below is capable of populating my combo box with the first and last name of staff from Active Directory (thanks to ZmrAbdulla). However, null values from Active directory fields are harming the results.
1. Filter out empty (null) values in the Givenname and SN fields.
2. I would like the option of inserting the results into a separate table rather than a combo box.
How can I accomplish these two items.
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
Me.ComboBox1.RowSourceType = "Value List"
While Not objRecordset.EOF
Me.ComboBox1.AddItem (objRecordset.Fields("givenname") & "," & objRecordset.Fields("sn"))
objRecordset.MoveNext
Wend
objConnection.Close
I truly appreciate any help.
The code below is capable of populating my combo box with the first and last name of staff from Active Directory (thanks to ZmrAbdulla). However, null values from Active directory fields are harming the results.
1. Filter out empty (null) values in the Givenname and SN fields.
2. I would like the option of inserting the results into a separate table rather than a combo box.
How can I accomplish these two items.
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
Me.ComboBox1.RowSourceType = "Value List"
While Not objRecordset.EOF
Me.ComboBox1.AddItem (objRecordset.Fields("givenname") & "," & objRecordset.Fields("sn"))
objRecordset.MoveNext
Wend
objConnection.Close
I truly appreciate any help.