![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
Yes, I know about ".Value". I've struck this issue on a number of different occasions but in this case I'm calling a routine which updates the StatusBar & ControlTipText properties in tandem as shown below... Function UpdateStatusBarControlTip(Ctl As Control, Text As String) On Error Resume Next With Ctl .StatusBarText = Text .ControlTipText = Text End With On Error GoTo 0 End Function Any ideas about the original question? |
#2
| |||
| |||
|
|
peter (AT) SunSpotCompDot (DOT) ComDot.Au (Peter Nurse) wrote in message news:<3efa4c16.8660945 (AT) news (DOT) bigpond.com>... Yes, I know about ".Value". I've struck this issue on a number of different occasions but in this case I'm calling a routine which updates the StatusBar & ControlTipText properties in tandem as shown below... Function UpdateStatusBarControlTip(Ctl As Control, Text As String) On Error Resume Next With Ctl .StatusBarText = Text .ControlTipText = Text End With On Error GoTo 0 End Function Any ideas about the original question? What's the problem with that code? |
#3
| |||
| |||
|
|
Allen, Allen, I suspect we're going round in circles a bit. I posted UpdateStatusBarControlTip() simply to demonstrate an instance in which you might want to pass an object to a function. Now, to ask the question again:- In this example... Sub MySub () With Forms("frmA").Controls("CtlA") .Visible = True .Enabled = True UpdateStatusBarControlTip .Object End With End Sub ...is there a way I can pass the object Forms("frmA").Controls("CtlA") to the function UpdateStatusBarControlTip() without repeating the whole object definition. |
|
As I said in the original post..."Yes, I know I can simplify this by using... Set Ctl = Forms("frmA").Controls("CtlA") ...but that is sidestepping the issue." Does that make it clear now? |
#4
| |||
| |||
|
|
You can pass Forms("frmA").Controls("CtlA") ... Should I conclude from your response that I can't pass the object to a sub/function and we just need to find a way to work around it? |
#5
| |||
| |||
|
|
Peter, I can't understand what you are talking about either. Passing Forms("frmA").Controls("CtlA") is not a workaround for passing an object. It *is* passing the object. So all the properties of that object are available whereever you pass it. |
#6
| |||
| |||
|
|
Sub A Dim theDog as Dog . . Set theDog = .... . . With theDog .Visible=True .Enabled = False . . KillTheDog ???? End With End Sub Function KillTheDog (theDog as Dog) . . . End Function |
#7
| |||
| |||
|
|
Most (if not all) of the traffic in this thread has been way off the origianl topic so...one last try after which I'll declare myself well and truly defeated! |
#8
| |||
| |||
|
|
I understand your question. You want to know if there is a universal, magical method that all Access and VBA Objects automatically have that returns a reference to itself. Something like Public Function ThisObject as (Object) ThisObject = Me End Function. So you could With theDog .Color = YELLOW .Rabies = True KillTheDog .ThisObject End With Private Sub KillTheDog (dg as clsDog) Call SobAndWeep dg.Euthanize Call BuryTheMutt End Sub The Object Browser says nope. |
#9
| |||
| |||
|
|
Yes, within the WITH you have to repeat the reference. But who gives a rat's ass? If your question is: Can the object on which a WITH is based be passed to an outside subroutine using the WITH structure? Then the answer is NO. But why would it matter? A WITH structure is for making code within a subroutine easier to manage. It does not have applicability outside its own context. -- David W. Fenton http://www.bway.net/~dfenton dfenton at bway dot net http://www.bway.net/~dfassoc |
#10
| |||
| |||
|
|
And yes. It is possible. You could write. with ctl .killthedog end with All you have to do is write a method yourself.... Oh. Did I mention it wouldn't be easy? with ctl blaa end with killthedog(ctl) Is easy enough and has no particular overhead. So what's the problem? |
![]() |
| Thread Tools | |
| Display Modes | |
| |