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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refering to Control 1

Status
Not open for further replies.

georgp

Technical User
Mar 28, 2002
96
US
Hi,
in a module, I want to refer to a control (rectangle) which name is identified in the tag of another control (combobox):

Public Sub bss_PolySynth(rfrm As Form, Ctl As Control)
....
....
Forms!(rfrm.Name).Controls!(Ctl.Tag).BackColor = Ctl.BackColor
(and many other trials)
....
....
End Sub

I always get error messages (in this case: Type-declaration character does not match declared data type). Any suggestion for the correct syntax?

Thanks, georgp
 
Public Sub bss_PolySynth(rfrm As Form, Ctl As Control)
....
....
Forms(FormName)(ctl).backcolor = ctl.backcolor
....
....
End Sub


Not sure why you are trying to set the backcolor of the control to it's current value.
 
Hi!

Think you could shorten it a little. You are also combining reference methods. Try something like this:

[tt]rfrm.Controls(Ctl.Tag).BackColor = Ctl.BackColor[/tt]

Since you have passed the form, you don't need the Forms()...

HTH Roy-Vidar
 
Yep. Good call. I just coppied it from something I did about 10 years ago.

Thanks.
 
Roy,

thanks a lot - it works now as it should. A star for you - actually I have tried this syntax, but my tags did not have the correct name of the controls, so it failed due to a different reason.

Hneal98, thanks also anyway.
What I am doing is following:
I have comboboxes which can be edited only if the data owner opens the recordset. When editable they are e.g. white, otherwise e.g. yellow. Unfortunately, the dropdown arrows of the comboboxes made look the form somewhat cluttered (part of the form resembles a spreadsheet). So I decided to cover the arrows with a rectangle with the same color as the combobox (i.e. they have to be sometimes white and sometimes yellow) and the respective arrow is only visible, when the box is entered. The tag of the combobox refers to the rectangle so that it's color is in line with that of the combobox.

Thanks both of you... Have good holidays and an exciting New Year.
georgp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top