Results 1 to 5 of 5

Thread: how to activate a macro when the activerecord changes

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Posts
    4

    how to activate a macro when the activerecord changes

    hello,

    im using using mailmerge to get data from access to word.
    I'm using a scrollbar to visually show of some data. I already wrote the code to attach the value of the field to the scrollbar but I can't find how to trigger this macro each time the active record changes to another one...

    Can anyone help me plz

    thx in advance !!!
    greetz
    hakiri

  2. #2
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: how to activate a macro when the activerecord changes

    Post the code you have!

    CS.

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Posts
    4

    Re: how to activate a macro when the activerecord changes

    Quote Originally Posted by cssriraman
    Post the code you have!

    CS.
    little problem... the word doc decided to crash :s
    guess i tried to much without taking a backup... so i will have to write it all over again... I'll post it when its ready

  4. #4

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Posts
    4

    Re: how to activate a macro when the activerecord changes

    this is the "quite easy" code that changes the values of the scrollbar to given value saved in a record from access...

    VB Code:
    1. Sub scrollbar_change()
    2. ActiveDocument.ScrollBar2.Value = ActiveDocument.MailMerge.DataSource.DataFields("abalet").Value
    3. ActiveDocument.ScrollBar3.Value = ActiveDocument.MailMerge.DataSource.DataFields("adm").Value
    4. ActiveDocument.ScrollBar4.Value = ActiveDocument.MailMerge.DataSource.DataFields("anabo").Value
    5. ActiveDocument.ScrollBar5.Value = ActiveDocument.MailMerge.DataSource.DataFields("fwt").Value
    6. ActiveDocument.ScrollBar51.Value = ActiveDocument.MailMerge.DataSource.DataFields("algo").Value
    7. ActiveDocument.ScrollBar511.Value = ActiveDocument.MailMerge.DataSource.DataFields("conclus").Value
    8. ActiveDocument.ScrollBar5111.Value = ActiveDocument.MailMerge.DataSource.DataFields("num").Value
    9. ActiveDocument.ScrollBar41.Value = ActiveDocument.MailMerge.DataSource.DataFields("rapid").Value
    10.  
    11.  
    12. End Sub

    now I'm looking 4 a way to call scrollbar_change whenever one of the actions written below takes place. So whenever one of theses actions should take place it should trigger scrollbar_change. I thought I had to write a macro called "document_open()" soit always reads when something should happen... but I could be mistaken





    VB Code:
    1. ActiveDocument.MailMerge.DataSource.ActiveRecord = wdNextRecord
    2. ActiveDocument.MailMerge.DataSource.ActiveRecord = wdPreviousRecord
    3. ActiveDocument.MailMerge.DataSource.ActiveRecord = wdLastRecord
    4. ActiveDocument.MailMerge.DataSource.ActiveRecord = wdFirstRecord


    thx for the help,
    really appreciate it
    hakiri

  5. #5

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Posts
    4

    Re: how to activate a macro when the activerecord changes

    okay, i searched for an alternate option... i made new buttons which couples the going to the next record and changing the scrollbars...

    the problem now is... it changes when i use it in combination with wdLastRecord and wdFirstRecord, but not with wdNextRecord and wdPreviousRecord. the error i get is that i can't set the value. illegal value fault 380.

    help plz


    VB Code:
    1. Sub scrollbar1_change()
    2.  ActiveDocument.MailMerge.DataSource.ActiveRecord = wdNextRecord
    3. ActiveDocument.ScrollBar2.Value = ActiveDocument.MailMerge.DataSource.DataFields("abalet").Value
    4. ActiveDocument.ScrollBar3.Value = ActiveDocument.MailMerge.DataSource.DataFields("adm").Value
    5. ActiveDocument.ScrollBar4.Value = ActiveDocument.MailMerge.DataSource.DataFields("anabo").Value
    6. ActiveDocument.ScrollBar41.Value = ActiveDocument.MailMerge.DataSource.DataFields("fwt").Value
    7. ActiveDocument.ScrollBar5.Value = ActiveDocument.MailMerge.DataSource.DataFields("algo").Value
    8. ActiveDocument.ScrollBar51.Value = ActiveDocument.MailMerge.DataSource.DataFields("conclus").Value
    9. ActiveDocument.ScrollBar511.Value = ActiveDocument.MailMerge.DataSource.DataFields("num").Value
    10. ActiveDocument.ScrollBar5111.Value = ActiveDocument.MailMerge.DataSource.DataFields("rapid").Value
    11.  
    12.  
    13.  
    14.  
    15. End Sub
    16. Sub scrollbar2_change()
    17.  ActiveDocument.MailMerge.DataSource.ActiveRecord = wdPreviousRecord
    18. ActiveDocument.ScrollBar2.Value = ActiveDocument.MailMerge.DataSource.DataFields("abalet").Value
    19. ActiveDocument.ScrollBar3.Value = ActiveDocument.MailMerge.DataSource.DataFields("adm").Value
    20. ActiveDocument.ScrollBar4.Value = ActiveDocument.MailMerge.DataSource.DataFields("anabo").Value
    21. ActiveDocument.ScrollBar41.Value = ActiveDocument.MailMerge.DataSource.DataFields("fwt").Value
    22. ActiveDocument.ScrollBar5.Value = ActiveDocument.MailMerge.DataSource.DataFields("algo").Value
    23. ActiveDocument.ScrollBar51.Value = ActiveDocument.MailMerge.DataSource.DataFields("conclus").Value
    24. ActiveDocument.ScrollBar511.Value = ActiveDocument.MailMerge.DataSource.DataFields("num").Value
    25. ActiveDocument.ScrollBar5111.Value = ActiveDocument.MailMerge.DataSource.DataFields("rapid").Value
    26.  
    27.  
    28. End Sub
    29. Sub scrollbar4_change()
    30.     ActiveDocument.MailMerge.DataSource.ActiveRecord = wdLastRecord
    31. ActiveDocument.ScrollBar2.Value = ActiveDocument.MailMerge.DataSource.DataFields("abalet").Value
    32. ActiveDocument.ScrollBar3.Value = ActiveDocument.MailMerge.DataSource.DataFields("adm").Value
    33. ActiveDocument.ScrollBar4.Value = ActiveDocument.MailMerge.DataSource.DataFields("anabo").Value
    34. ActiveDocument.ScrollBar41.Value = ActiveDocument.MailMerge.DataSource.DataFields("fwt").Value
    35. ActiveDocument.ScrollBar5.Value = ActiveDocument.MailMerge.DataSource.DataFields("algo").Value
    36. ActiveDocument.ScrollBar51.Value = ActiveDocument.MailMerge.DataSource.DataFields("conclus").Value
    37. ActiveDocument.ScrollBar511.Value = ActiveDocument.MailMerge.DataSource.DataFields("num").Value
    38. ActiveDocument.ScrollBar5111.Value = ActiveDocument.MailMerge.DataSource.DataFields("rapid").Value
    39.  
    40.  
    41. End Sub
    42. Sub scrollbar3_change()
    43.     ActiveDocument.MailMerge.DataSource.ActiveRecord = wdFirstRecord
    44. ActiveDocument.ScrollBar2.Value = ActiveDocument.MailMerge.DataSource.DataFields("abalet").Value
    45. ActiveDocument.ScrollBar3.Value = ActiveDocument.MailMerge.DataSource.DataFields("adm").Value
    46. ActiveDocument.ScrollBar4.Value = ActiveDocument.MailMerge.DataSource.DataFields("anabo").Value
    47. ActiveDocument.ScrollBar41.Value = ActiveDocument.MailMerge.DataSource.DataFields("fwt").Value
    48. ActiveDocument.ScrollBar5.Value = ActiveDocument.MailMerge.DataSource.DataFields("algo").Value
    49. ActiveDocument.ScrollBar51.Value = ActiveDocument.MailMerge.DataSource.DataFields("conclus").Value
    50. ActiveDocument.ScrollBar511.Value = ActiveDocument.MailMerge.DataSource.DataFields("num").Value
    51. ActiveDocument.ScrollBar5111.Value = ActiveDocument.MailMerge.DataSource.DataFields("rapid").Value
    52.  
    53.  
    54. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width