Accessing query results with VBA

  • Thread starter Thread starter burgerj
  • Start date Start date
B

burgerj

Guest
Using ADO to access a table. Here's my example. My question is "Can I access a query result in a similar way?

Public Function ReplaceGroupMembership(asset As String)

Const ADS_PROPERTY_APPEND = 3
Dim rs As New ADODB.Recordset

'ADO code to open the table/recordset
rs.Open "tblComputers_from_AD_Base_Image", CurrentProject.Connection, adOpenKeyset, adLockOptimistic

Do Until rs.EOF
Set objGroup = GetObject("LDAP://cn=" & asset & ",ou=Deployment,ou=NFSC,dc=mybank,dc=com")
objGroup.PutEx ADS_PROPERTY_APPEND, "member", _
Array("cn=" & rs.Fields("ComputerName") & ",ou=Computers,ou=NFSC,dc=mybank,dc=com")
objGroup.SetInfo
rs.MoveNext
Loop

MsgBox "Active Directory Update Complete"

End Function
 
Have you tried just changing the name of the table to the name of the query?
 

Users who are viewing this thread

Back
Top Bottom