Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740

    Unanswered: set .controlsource in UserForm_Initialize

    i have a UserForm with

    _Activate()
    Me.boxLastName = Worksheets("dPeople").Cells(Me.boxRow, cstLastName)

    _Terminate()
    Worksheets("dPeople").Cells(Me.boxRow, cstLastName) = Me.boxLastName

    everything is working fine, but i am unhappy manually-feeding and later manually-harvesting 50 controls.

    all my attempts at setting
    Me.boxLastName.ControlSource = Xxxxxxxxxxxxxx
    at _Activate or _Initialize() have failed!

    any hints are very welcome.

    izy

    LATER: can't edit the topic but it should have read
    set .ControlSource in UserForm_Initialize or _Activate
    ...and i have tried literals in place of Me.boxRow in both events - zilch!
    Last edited by izyrider; 12-31-06 at 12:06.
    currently using SS 2008R2

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740

    progress (not a lot)

    Me.boxFirstName.ControlSource = Worksheets("dPeople").Cells(Me.boxRow, cstFirstName).Address

    in _Activate has fixed the error messages, but a known-populated cell comes up empty

    hmmmm

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    réglé!

    Me.boxFirstName.ControlSource = Worksheets("dPeople").Cells(Me.boxRow, 7).Address(, , xlA1, True)

    and it works!
    .Address makes a lot of sense, but the (, , xlA1, True) is currently a magic mystery.

    izy
    currently using SS 2008R2

  4. #4
    Join Date
    Mar 2006
    Posts
    163
    I'm not 100% sure what you are asking but you can loop through a forms controls collection like this.
    Code:
    For Each ctl In Me.Controls
         Msgbox "Control " & ctl.Name & " is a" & TypeName(ctl)
    Next ctl

Posting Permissions

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