Welcome to Forums Sign in | Join | Help | Forums
in Search





Make the world a better place.

Removing Addresses

Last post 11-13-2008 6:15 AM by Mike Diplock. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 11-09-2008 7:58 AM

    Removing Addresses

    Has anyone successfully removed an address from a constituent using VBA? I am tidying up records after an import and am trying to remove lots of empty address fields using a plug-in written in VB6. I'm reasonably experienced in writing plug-ins but CConstitAddresses does not seem to be behaving the same as other RE collections like CConstituentCodes.

    The code is:

    Dim oRec As CRecord, oConsAdds As CConstitAddresses
    Set oRec = New CRecord
    oRec.Init moSC
    oRec.Load 1605
    Set oConsAdds = oRec.Addresses
    oConsAdds.Remove 1,True
    oRec.Save
    oRec.
    CloseDown

    This should remove the first address from constituent '1605' but nothing happens when the code runs. Has anyone tried something similar with success?

     

    Filed under:
  • 11-09-2008 1:19 PM In reply to

    • David Zeidman
    • Top 25 Contributor
    • User Since: 2002
    • Posts 205
    • Organization: Zeidman Development
    • Products:  Blackbaud Direct Marketing, Blackbaud Enterprise CRM, The Information Edge, The Raiser's Edge

    Re: Removing Addresses

     So I am not quite sure this is correct. The line

    oConsAdds.Remove 1,True

     Will not work as you expect. The  1 is the address id. Alternatively you need to supply the actual CConstitAddress object and that will work.

     David

    David Zeidman
    Zeidman Development
    http://www.zeidman.info

    Check out my RE API blog
    http://www.re-decoded.com
  • 11-13-2008 6:15 AM In reply to

    Re: Removing Addresses

    Thanks David,

    You are right that in that using the object directly does work. The documentation for VBA says there are two ways to remove a child from a collection, with the collection item number or the object. I have always used the item number on other collections and didn't realise the object removal existed. For those interested the working code is:

    Dim oRec As CRecord, oConsAdds As CConstitAddresses, oAddr as CConstitAddress
    Set oRec = New CRecord
    oRec.Init moSC
    oRec.Load 1605
    Set oConsAdds = oRec.Addresses
    Set oAddr = oConsAdds.Item(1)
    oConsAdds.Remove oAddr,True
    oRec.Save
    oRec.CloseDown

Page 1 of 1 (3 items)