[AccessD] variable as object

John Clark John.Clark at niagaracounty.com
Mon Aug 1 09:36:33 CDT 2005


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






More information about the AccessD mailing list