Log in

View Full Version : Reloading a userform for more entries



MRWinAVL
06-06-2013, 12:57 PM
I followed Greg Maxey's student survey form to create a userform with two text boxes, one list box, and a couple optionbuttons. Happy to say it works just like I wanted it to. It collects a person's name and a few details, and then drops that information into the active document using variables instead of bookmarks.

But the document itself is a boilerplate paragraph, followed by this individual's information, followed by some more boilerplate. And the problem I have is that it could be just one individual listed this time, but 4 individuals the next time, 8 the next, 2 the next, and so on. I want the userform to popup, take my entries, drop them in the doc, and then repeat...until I click the button that says "Cancel".

I can't figure out what to put in either the cmd_OKClick sub or in the CallUF() sub to make it repeat/refresh. A little new to this, so dummied-down help appreciated! :yes

SamT
06-08-2013, 08:27 AM
I am not familiar with Greg Maxey's student survey form so I have no idea what your code looks like ATT. I assume that the CallUF() sub is what you're using to show the Form and that the cmdOK_Click sub inserts the data and closes the Form.

Add a CommandButton to close the form and move the Form closing code to that button's On_Click sub and change the Caption of the cmdOK button to "Save Data."

Personally, I would move the SaveData and ClearForm codes to new subs and call them from the SaveData CommandButton. That way the Cancel Button can also call the ClearForm() sub without closing the Form.

The CloseForm() sub can call a sub that checks if there is any unsaved data in the form.