View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
James James is offline
external usenet poster
 
Posts: 542
Default Combo Box on User Form Question

I frequently have a problem with Excel crashing when running VBA code to open
an user form. The error message reads "Microsoft Office Excel has encountered
a problem and needs to close" and requires termination of the program. This
error also always happens when the VBA project is locked (i.e., if I enter
the password to view the VBA code upon opening the workbook it never occurs.)

Error trapping has shown that the problem takes place on the line of code
that assigns an initial value to the combo box cboVSMName in the
UserForm_Initialize event. Basically, the objective of this code is to fill
the combo box with the value that was last selected by an user. Cell D100 is
assigned the value of the combo box before unloading the user form. The
UserForm_Initialize code is shown below.

Private Sub UserForm_Initialize()

Dim FillValue As String

Call FillOtherCombos
Call FillMapCombo

FillValue = Sheets("Entry Sheet").Range("D100").Value

cboVSMName.Value = FillValue

End Sub

It may also be worth noting that there is a Change event tied to cboVSMName
that changes the value of some text boxes on the form whenever a different
selection in the combo box is made.

Does anybody have some ideas of why this may be happening or have some
suggestions on how I can modify the code to prevent this from happening? More
specifically, is there a more intelligent way than what I have done to assign
the starting value of a combo box to the last item selected before the form
was unloaded when initializing a form?

Thanks,

James