Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can Control Names be passed to a Private Sub? 2

Status
Not open for further replies.

delman333

Technical User
Oct 20, 2003
32
US
Two things:

First I've received a lot of help through this forum...in which case I've given credit to the individual who helped. However, sometimes I take the not-so-exact suggestions from several people and combine them to achieve exactly what I want. Should I be giving credit to all of them? Or only to those who individually present a specific solution?

Ok...I know I can pass variables around...but can I pass different Control names to a single Private Sub that will then perform the same routine on whichever group of controls I sent to it?

Thanks in advance.
 
if you're just searching through old posts, you don't usually have to give stars to information that you've found there, if someone is helping you directly it usually considered good etiquette to give them a star if they solve your problem.

as for your second question, if you pass control names to a private sub, they will just be strings. If you want to perform operations on the controls that you passed, you can pass a reference to the control, something like the following

private sub blah(stuff as control)
stuff.value = "whatever"
end sub

blah (txtstuff)

simple I know, but it should give you the basic idea.
 
Hi!

To build a little on jimb0ne's answer, should you need to do things with more than one control, passing the whole form might be something:

[tt]Call DoSomething(Me, "txtSomeControl")

Sub DoSomething(byref frm as Form, byval sCtlName as string)
dim ctl as control
for each ctl in frm.controls
if typeof ctl is textbox then
' do something
if ctl.name = sCtlName
' perform something
end if
end if
if typeof ctl is combobox then
' do something
end if
next ctl[/tt]

For instance - if you pass both the form and the name of a control, you could check for the name and perform actions on the control matching the criteria. You could build it further to for instance take different actions etc.

Should you want to use a select case version, then the controltype property of the control might be used.

[tt]select case ctl.controltype
case acTextBox
case acComboBox...[/tt]

Stars 'nstuff: I think the most important, is to give feedback nomatter if the suggestions in the thread provided solutions to current challenge or not. If solutions where not found among the suggestions in a thread, but you found it yourself, perhaps based on some idea posted in the thread, you should also state that. So in the scnenario you describe, I'd say that; member1's suggestion on "blah blah1", combined with member2's suggestion on "blah blah2" provided me with... Feedback is also credit!

Point is to 1. make it possible for others to search the TT database and find solutions to their own challenges 2. give necessary feedback to tipsters whether their suggestions where appropriate regarding the current challenge or not (we're all here to learn). 3. Just think about your motivation to assist others when no reply/feedback is given vs where feedback was given. 4. If one or more of the suggestions in the thread really provides helpful advice, star thingies can also be applied. This has more than one effect, first being off course to award tipsters, but also important, when searching thru TT database with keywords relating to ones current challenge, threads having a star or more, would often mean there's more likelihood of finding good suggestions/advice.

HTH Roy-Vidar
 
The combination of your suggestions pointed me in the right direction.

Thanks to both of you.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top