Results 1 to 9 of 9
  1. #1
    Star Lounger
    Join Date
    May 2003
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have a basic memo template that shows a user form on open. The form includes recipient, from, date, cc, subject.
    When I click OK, the info from the form is placed in to enclosing bookmarks.
    The date and recipient name are also on the second page header.

    Once the form has been completed, and the document is populated with information from the user form, how can I show the form without losing the input data?
    I have a ShowUserForm macro to open the form but don't know how to have it "hold" the info from the first form.

    Sub ShowForm()
    frmMemo.Show
    End Sub

    If I show the form while in the newly created word document, the user form is empty. I can add new info and it will re-populate my document. But, if I don't complete all of the fields, I lose that info.
    If I show the user form again, the new info I added is still there.
    Why does it work on the second try and not on the initial launch?
    Thanks!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    The template attached to Post 259183 shows how to do this. The values are stored in document variables, and the UserForm_Initialize event is used to populate the form with these values.

  3. #3
    Star Lounger
    Join Date
    May 2003
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='773157' date='30-Apr-2009 20:06']The template attached to Post 259183 shows how to do this. The values are stored in document variables, and the UserForm_Initialize event is used to populate the form with these values.[/quote]


    The user form initialize doesn't work once I complete the fields. I am using enclosed bookmarks to fillin the memo, not doc variable fields (I was back and forth on pros and cons of each and ultimately decided bookmarks met my needs)
    I can call the user form back up with a macro, but can't get it to pull the values until the 2nd time it loads. This is what I do:

    New document from .dot
    complete user form
    Memo populates fields.
    Today becomes tomorrow. Need to update date in 2 (sometimes 3) places so run user form macro again to change date info.
    Presented with blank user form
    Complete form again
    THEN, if I run macro to show form again, all fields stick.

    I need this to happen on initial launch.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Could you create a copy of your template with superfluous and sensitive information removed, zip the copy and attach the zip file to a reply?

  5. #5
    Star Lounger
    Join Date
    May 2003
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [attachment=83545:SampleMemo.zip]
    This is the memo template. You will see that the date is set by default, but is not an auto update field.
    The concern is that someone will create the memo today and then hold for a few days. It's not unusual for a user to neglect to update the date on the second page header so I want to give them option to change date (through showing the form again)

    Note: If the cc field is left blank, the cc row in the table will be deleted (which doesn't concern me at the moment...)

    Thanks Hans!
    Attached Files Attached Files

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    [quote name='techtrain' post='773209' date='30-Apr-2009 17:50']The concern is that someone will create the memo today and then hold for a few days. It's not unusual for a user to neglect to update the date on the second page header so I want to give them option to change date (through showing the form again)[/quote]
    Is the bookmark around the date preserved after the user updates the date? If so, the second page header should refresh after a Print or Print Preview, or you could use code to update the fields in the header. That seems easier that requiring the user to enter something...

    If there is a danger that the bookmark will be deleted, you could create a unique style name for the contents of the date cell and use a STYLEREF field in your header.

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    The reason that the data are displayed the second time is that you don't unload the userform, you merely hide it, so it remains in memory as long as the document is open. Bu when the document is closed, the userform is unloaded and the information disappears.

    In the attached version, I've used the Initialize event of the userform to populate it from the bookmarks.
    I've removed the code to delete the CC row - if you do, you can't add a CC recipient later on.
    Attached Files Attached Files

  8. #8
    Star Lounger
    Join Date
    May 2003
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='773230' date='01-May-2009 09:35']The reason that the data are displayed the second time is that you don't unload the userform, you merely hide it, so it remains in memory as long as the document is open. Bu when the document is closed, the userform is unloaded and the information disappears.

    In the attached version, I've used the Initialize event of the userform to populate it from the bookmarks.
    I've removed the code to delete the CC row - if you do, you can't add a CC recipient later on.[/quote]

    Great, thanks. But, I have to delete the cc row because these users have NO idea how to delete a table row!
    Appreciate the help.

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Why not simply leave the CC row? If you delete it, you'll run into trouble (i) when the user displays the userform again (the code will try to read the cc bookmark) and (ii) when the user clicks OK in the userform (the code will try to set the cc bookmark).

Posting Permissions

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