[SOLVED] Connect Datasheet form to Active Directory Search Results
Hi All,
I'm trying to tie a from into the results from and AD Query.
I'm not that experienced with doing this kind of thing so I may be going about this the wrong way.
Anyway here's what I've got so far:
When stepping through the code, it all goes well until it hits the line that actually connects it to the form "Set Me.Recordset = rs".
When this line is executed, Access crashes and attempts to restart.
Any ideas what I'm doing wrong?
PS: Access 2010, Win7 64bit
Hi All,
I'm trying to tie a from into the results from and AD Query.
I'm not that experienced with doing this kind of thing so I may be going about this the wrong way.
Anyway here's what I've got so far:
Code:
Private Sub Form_Open(Cancel As Integer)
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection
With cn
.ConnectionString = "Provider=ADSDSOObject;Trusted_Connection=yes;"
.Open
End With
Set rs = New ADODB.Recordset
With rs
Set .ActiveConnection = cn
.Source = "SELECT mail, cn From 'LDAP://DC=my,DC=domain,DC=com' WHERE memberOf='CN=MYGROUP,OU=Groups,OU=GroupOU,OU=MY,DC=domain,DC=com' AND objectCategory='user'"
.Open
End With
'Set the form's Recordset property to the ADO recordset
Set Me.Recordset = rs
Set rs = Nothing
Set cn = Nothing
End Sub
When stepping through the code, it all goes well until it hits the line that actually connects it to the form "Set Me.Recordset = rs".
When this line is executed, Access crashes and attempts to restart.
Any ideas what I'm doing wrong?
PS: Access 2010, Win7 64bit
Last edited: