Thread: Userforms
View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Userforms

Your correct. Thanks! I created a new ComboBox using the same code and it
worked, so I apparent messed-up the RowSource on the original combo box when
I decided to load the data using my array versus cells in a spreadsheet.

Thanks as usual for your help!

Bob

"Dave Peterson" wrote:

I'm betting that you have assigned the .rowsource to a range -- either in code
or when you were in design mode.

So remover that line from your code or manually fix the .rowsource property --
or do it in code:

I think there's lots of things that could be going wrong, but you haven't shared
enough about what's happening.

This worked fine for me:

Option Explicit
Private Sub UserForm_Initialize()

Dim i As Long
Dim SystemType() As mySystemType

Me.ComboBox1.RowSource = ""

ReDim SystemType(1 To 3)

'some test data
For i = 1 To 3
SystemType(i).Name = "a" & i
SystemType(i).myVar1 = i * 10
SystemType(i).myVar2 = i * 100
Next i

For i = 1 To 3
Me.ComboBox1.AddItem SystemType(i).Name
Next i
End Sub


Bob wrote:

That fixed that problem, thanks. Now I have an issue with the Array I
created with the Type declariation. Below is the sample code located in
UserForm1 code:
For i = 1 To 3
Tmp = SystemType(i).Name
UserForm1.CBox1.AddItem Tmp
Next i
When my code gets to UserForm1.CBox1.AddItem TMP I receive an erro message
stating Run-time error '70': Permission denied. So I guess I don't
understand how to add an item to my Combo Box.

"Dave Peterson" wrote:

Put the type in a General module and make it public.

Public Type MyVar
var1 as long
var2 as string
End Type


Bob wrote:

In my module1 code I'm using a Type statement. The Userform1 doesn't appear
to support Type declariations. I get a compiler error "Can not define a
Public user-defined type within an object module.

Bob

"royUK" wrote:


The code really neds to be in the userform module.


--
royUK

Hope that helps, RoyUK
For tips & examples visit my 'web site' (http://www.excel-it.com/)
------------------------------------------------------------------------
royUK's Profile: http://www.thecodecage.com/forumz/member.php?userid=15
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=45431



--

Dave Peterson


--

Dave Peterson