Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    London, United Kingdom
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts

    user defined types in user forms (2003)

    Hi All

    I have a user form that has an array with a userdefined type.
    The user defined type is declared in a module called declarations and the code is:
    Type uHTMLPublish
    strMonth As String
    strPublshType As String
    curRevenue As Currency
    End Type

    I am then using the user defined type to collect values from a user form. The code behind the ok button on the user form is:
    Dim muHTMLPublish(1 To 12) As uHTMLPublish
    Private Sub cmdOK_Click()
    Dim intCount As Integer
    Dim booSuccess As Boolean
    For intCount = 1 To 12
    With Controls("cbo" & Format("01/" & intCount & "/01", "mmm"))
    muHTMLPublish(intCount).strPublshType = .Text
    muHTMLPublish(intCount).strMonth = Format("01/" & intCount & "/01", "mmm")
    End With
    Next
    Me.Hide
    End Sub

    To retrieve the user defined array I am using the following also on the form:

    Property Get HTML() As uHTMLPublish
    HTML = muHTMLPublish()
    End Property

    I would then like to access the data in muHTMLPublish(1 To 12) from a normal module.

    So I am trying to do something like this
    Sub RetrieveMonths()
    Dim frmHTML As frmHTMLPublish
    Dim uHTML(1 To 12) As uHTMLPublish

    Set frmHTML = New frmHTMLPublish
    uHTML = frmHTMLPUBLISH.HTML

    This does not work and I can't seem to find a way to retrieve my userdefined array from the form.

    Any help with this would be greatly appreciated.

    Many thanks

    Amanda Battye

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: user defined types in user forms (2003)

    Try

    Dim frmHTML As frmHTMLPublish
    Dim uHTML() As uHTMLPublish
    Set frmHTML = New frmHTMLPublish
    frmHTML.Show
    uHTML = frmHTML.HTML

    Note the changed declaration of uHTMLPublish

    I added a line to show the userform - otherwise the HTML property will remain blank (I suppose)

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: user defined types in user forms (2003)

    I think you have to declare the type public:

    Public Type uHTMLPublish
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

Posting Permissions

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