UserForm - Load Combo boxes

A

Anne P.

I have a userform in a Memo template with a Combo Box which lists Atty info
(this info is stored in a template named Personal.dot). There is also a
command button which when clicked opens a new userform where atty info
filled in and saved, edited or deleted. When the memo is first run, the
combo box contains all stored atty info. However, if the user clicks the
command button to add, edit or delete atty info, when they are returned to
the Memo template userform, the combo box with the user info is not updated
with the new information.

I have the following code placed in the userform_activate event. (All
variables are declared and Option Explicit is on). I initially had it in
the Initialize event of the userform but it did not work, so I moved it to
Activate, but it still does not work. I don't know if it is the code, or if
I am using the wrong event.

=========================================================
mstrGlobalPath = Options.DefaultFilePath(wdStartupPath) & "\SKGlobal.dot"

Set mObjGlobal = Templates(mstrGlobalPath)

mstrPersonalPath = Options.DefaultFilePath(wdStartupPath) &
"\Personal.dot"

Set mObjPersonal = Templates(mstrPersonalPath)



'Fill Offices combobox with letterhead choices from SKGlobal

For Each mObjAtE In mObjGlobal.AutoTextEntries

If mObjAtE.StyleName = "logoAddress" Then

If Left(mObjAtE.Name, 2) = "NY" Or Left(mObjAtE.Name, 2) = "DC" Then

cmbOffices.AddItem mObjAtE.Name

End If

End If

Next mObjAtE

'Fill Re Line combobox with relines

For Each mObjAtE In mObjPersonal.AutoTextEntries

If mObjAtE.StyleName = "ReLine" Then

cmbReLine.AddItem mObjAtE.Name

End If

Next mObjAtE

'Fill user combobox

For Each mObjAtE In mObjPersonal.AutoTextEntries

If mObjAtE.StyleName = "UserInfo" Then

cmbAtty.AddItem mObjAtE.Name

End If

Next mObjAtE



================================================

I would appreciate any insight to fixing this problem.

Thanks, Anne P.
 
M

moi

Anne, I made a simple sample form in Word with MessageBoxes in both the
Activate and Initialize events. When the form is launched they both popup,
telling me Init! & Activate! So far so good.
However, if I put a button on the mainform which launches a 2nd userform and
I close that, there is no MessageBox at all.
Point to the point - both Initialize and Activate are ONLY called when the
mainform starts up*. Tada. This means your combobox is only filled with the
correct data when it's opened from Memo.dot.


What if you do this?

Create a subroutine UpdateComboBox, and put your code to fill the ComboBox
in there.

In your Initialize-routine you only say: Call UpdateComboBox, so it's being
filled with stuff from Personal.dot when the form starts up.

Then, add data, delete data, edit data, save data with the second form, and
if it's closed, call your UpdateComboBox routine again, which will fill the
combo with updated data.


* I'm not sure, but I think this is not the same as in Excel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top