PC Review


Reply
Thread Tools Rate Thread

How do I assign a control to a variable AS Control

 
 
Wes from Scottsdale
Guest
Posts: n/a
 
      10th Oct 2008
Dim cControl As Control

cControl = Me.cboSomething

I can pass cboSomething into a function as a control, but I need to retain
the control for later use.

Thanks.
 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      11th Oct 2008
Sorry, I don't understand exactly what you're trying to do. Can you give a
more detailed explanation?

"retain the control for later use" where? In the same procedure" There
shouldn't be any issue. What problem are you having?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Wes from Scottsdale" <(E-Mail Removed)> wrote in
message news:9EDFCBE9-6694-4287-9BC9-(E-Mail Removed)...
> Dim cControl As Control
>
> cControl = Me.cboSomething
>
> I can pass cboSomething into a function as a control, but I need to retain
> the control for later use.
>
> Thanks.



 
Reply With Quote
 
Wes from Scottsdale
Guest
Posts: n/a
 
      13th Oct 2008
I'm passing a control to a function. I want to save the control to a module
variable so that I can reference the passed control later outside of the
function.

Dim cLastControl As Control 'Module Level
Private Function A(cControl As Control)
cLastControl = cControl '**This fails**
'Rest of function code...
End Function

"Douglas J. Steele" wrote:

> Sorry, I don't understand exactly what you're trying to do. Can you give a
> more detailed explanation?
>
> "retain the control for later use" where? In the same procedure" There
> shouldn't be any issue. What problem are you having?
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Wes from Scottsdale" <(E-Mail Removed)> wrote in
> message news:9EDFCBE9-6694-4287-9BC9-(E-Mail Removed)...
> > Dim cControl As Control
> >
> > cControl = Me.cboSomething
> >
> > I can pass cboSomething into a function as a control, but I need to retain
> > the control for later use.
> >
> > Thanks.

>
>
>

 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      13th Oct 2008
You need to use the Set keyword when dealing with controls:

Set cLastControl = cControl


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Wes from Scottsdale" <(E-Mail Removed)> wrote in
message news:110DFBB0-DAF2-4E74-8E35-(E-Mail Removed)...
> I'm passing a control to a function. I want to save the control to a
> module
> variable so that I can reference the passed control later outside of the
> function.
>
> Dim cLastControl As Control 'Module Level
> Private Function A(cControl As Control)
> cLastControl = cControl '**This fails**
> 'Rest of function code...
> End Function
>
> "Douglas J. Steele" wrote:
>
>> Sorry, I don't understand exactly what you're trying to do. Can you give
>> a
>> more detailed explanation?
>>
>> "retain the control for later use" where? In the same procedure" There
>> shouldn't be any issue. What problem are you having?
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no private e-mails, please)
>>
>>
>> "Wes from Scottsdale" <(E-Mail Removed)> wrote
>> in
>> message news:9EDFCBE9-6694-4287-9BC9-(E-Mail Removed)...
>> > Dim cControl As Control
>> >
>> > cControl = Me.cboSomething
>> >
>> > I can pass cboSomething into a function as a control, but I need to
>> > retain
>> > the control for later use.
>> >
>> > Thanks.

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assign a Ribbon Control's Label from a Variable in VBA Code jean grey Microsoft Excel Programming 3 27th Jan 2009 05:47 AM
how do I assign a variable to a check box or radio control? tlscorpadmin Microsoft Access Forms 1 22nd Feb 2008 02:39 AM
Assign a control to variable MattB Microsoft ASP .NET 2 26th Sep 2005 10:52 PM
Can you assign a control name to a variable of some type idk Microsoft Access Form Coding 2 1st Aug 2004 01:43 PM
Setfocus to a control where name of control saved in variable or field Andrew Microsoft Access Forms 4 26th Feb 2004 01:04 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:43 AM.