If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > set .controlsource in UserForm_Initialize

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-30-06, 13:22
izyrider izyrider is offline
Cavalier King Charles
 
Join Date: Dec 2002
Location: Préverenges, Switzerland
Posts: 3,729
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!
__________________
currently using SS 2008R2

Last edited by izyrider; 12-31-06 at 11:06.
Reply With Quote
  #2 (permalink)  
Old 12-30-06, 13:54
izyrider izyrider is offline
Cavalier King Charles
 
Join Date: Dec 2002
Location: Préverenges, Switzerland
Posts: 3,729
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
Reply With Quote
  #3 (permalink)  
Old 12-30-06, 13:59
izyrider izyrider is offline
Cavalier King Charles
 
Join Date: Dec 2002
Location: Préverenges, Switzerland
Posts: 3,729
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
Reply With Quote
  #4 (permalink)  
Old 01-01-07, 15:38
norie norie is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On