Jim DeMarco
Jdemarco at hudsonhealthplan.org
Mon Aug 1 10:28:41 CDT 2005
It looks like you're referring to your control via a string not a control object. Try something like: Me.Controls(lblst).BackColor HTH Jim DeMarco -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of John Clark Sent: Monday, August 01, 2005 10:37 AM To: accessd at databaseadvisors.com Subject: [AccessD] variable as object I am playing around with a new menu interface, and I am trying to streamline it a bit, so that it may be reused for different menus with different quantities of buttons. For instance my main menu has only three buttons, while the reports menu has nine. Basically, I have invisible buttons over labels, and I set the focus on a MouseMove and, when the focus is set, I change the BackColor and ForeColor of the label to emphasize the current button. I am trying to use the function below to set all buttons to their default state, and then set the current button to the "special" color scheme. However, I am getting the error message, "Object Required" and it refers to both the with statements. If I comment out these two statements and add in a "Label38.caption = lblst" the caption of this test label does change properly as I move the mouse over the buttons. Can I please get a fresh set of eyes to point out my failing on this? ________________________________________________________________________________________________- Public Function BtnChange(BtnNum As String, BtnQuan As Integer) '***** I call this function from each of the OnFocus events of the command buttons, using the syntax "BtnChange 1, 9" '***** 1 is the actual button number and thus changes for each button...they are named lbl01 to lbl09. '***** 9 is the total num of buttons and does not change. Dim x As Integer Dim y As String Dim lblst As Variant '*** I did have this set to string, but have changed in an effort to fix the problem *** x = 1 While x < BtnQuan y = CStr(x) lblst = "lbl0" & y With lblst .BackColor = 10066329 .ForeColor = 0 End With x = x + 1 Wend lblst = "lbl0" & BtnNum Label38.Caption = lblst '*** this is just a test statement I put in to verify up to a point. With lblst .BackColor = 6381921 .ForeColor = 6670333 End With End Function _______________________________________________________________________ Thank you! John W Clark -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com *********************************************************************************** "This electronic message is intended to be for the use only of the named recipient, and may contain information from Hudson Health Plan (HHP) that is confidential or privileged. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the contents of this message is strictly prohibited. If you have received this message in error or are not the named recipient, please notify us immediately, either by contacting the sender at the electronic mail address noted above or calling HHP at (914) 631-1611. If you are not the intended recipient, please do not forward this email to anyone, and delete and destroy all copies of this message. Thank You". ***********************************************************************************