Sub ClearSecurityID()

 Dim oMemberships As CMemberships
 Dim oMembership As CMembership
 Dim sCustomWhere As String

 'String that contains everything after the WHERE in a SQL statement
 'Narrows down to just memberships where the membershipID is blank
 sCustomWhere = "MemID is not null"
 Set oMemberships = New CMemberships

 'Loads the collection of memberships using the where clause
  oMemberships.Init REApplication.SessionContext, tvf_Membeship_CustomWhereClause, sCustomWhere

 'loops through the collection of memberships
  For Each oMembership In oMemberships
   On Error Resume Next
     oMembership.ReadOnlyMode = False
     oMembership.Fields(MEMBERSHIP_fld_MemID) = ""
     oMembership.ReadOnlyMode = True

     'need to closedown membership before looping to the next membership

     If Err.Number <> 0 Then
       MsgBox "Aborting - " & Err.Description, vbCritical
       'if an error occurs exits the for loops - added error message to the msgbox
       Exit For
     End If
   On Error GoTo 0

 Next oMembership

 'let go of the membership omembership was using
  Set oMembership = Nothing
  MsgBox "Finished clearing all Member IDs.", vbDefaultButton1
  'closing down membership collection
Set oMemberships = Nothing

End Sub

Disclaimer: We provide programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes you are familiar with Microsoft Visual Basic and the tools used to create and debug procedures. Blackbaud Customer Support may help explain the functionality of a particular procedure, but we will not modify, or assist you with modifying, these examples to provide additional functionality.