OnClick event for labels

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi again,

Is there way to capture the value in the OnClick event for a label. I want
to be able to perform an action if a user clicks on a label named
"lblAdmin_Click()".

I get error messages when trying these references:

Me.lblAdmin.Value
Me.lblAdmin_Click.Value
Forms!StudentProfile!lblAdmin.Value

Please advise on what's wrong and what I can do.

-AKA
 
Hi again,

The action I want to do is the following:

I have a table named Departments with these fields:

Department_ID Department
1 Administration
2 Clinical
3 Laboratory

So, if a user clicks on the label "Administration" I want assign the
Department_ID for Adminstration to a variable, and so forth for the other
departments.

Can this be done?

-AKA
 
Hi again,

Is there way to capture the value in the OnClick event for a label. I want
to be able to perform an action if a user clicks on a label named
"lblAdmin_Click()".

I get error messages when trying these references:

Me.lblAdmin.Value
Me.lblAdmin_Click.Value
Forms!StudentProfile!lblAdmin.Value

Please advise on what's wrong and what I can do.

-AKA

Labels which are attached to a text control do not have any events.
Labels which are not attached to a text control do have events, so you
can write an [Event Procedure] in the click event of a label.

I haven't a clue as to what it is you are trying to accomplish by
clicking on a label, so I'll quit while I'm ahead. :-)
 
Fredg,
I haven't a clue as to what it is you are trying to accomplish by
clicking on a label, so I'll quit while I'm ahead. :-)

Those lines made me laugh and I needed a good laugh today :-)

I should have mentioned that the labels serve as buttons. I know your
probably thinking "Why not just use a command button". Well, the buttons in
access are quite dull looking and don't quite fit in with my forms color
scheme. So, I chose to use labels with colors and shading that blend well
with everything else.

Anyway, the labels are not attached to any controls so when a user clicks
them I want to be able to assign the Department ID from the Departments table
to a variable and pass it to a function. So, if the user clicks the Admin
label I need to lookup the Department ID for Administration and pass it to
the function.

Does this make sense at all?

-AKA



fredg said:
Hi again,

Is there way to capture the value in the OnClick event for a label. I want
to be able to perform an action if a user clicks on a label named
"lblAdmin_Click()".

I get error messages when trying these references:

Me.lblAdmin.Value
Me.lblAdmin_Click.Value
Forms!StudentProfile!lblAdmin.Value

Please advise on what's wrong and what I can do.

-AKA

Labels which are attached to a text control do not have any events.
Labels which are not attached to a text control do have events, so you
can write an [Event Procedure] in the click event of a label.

I haven't a clue as to what it is you are trying to accomplish by
clicking on a label, so I'll quit while I'm ahead. :-)
 
Hi again,


Disregard previous posts. I found out how to achieve what I needed. I used
this:

Private Sub lblAdmin_Click()
Dim myDept as Variant
myDept = DLookup("[Department_ID]", "Departments", "[Department] =
'Administration'")
myDept = LoadList(myDept)
end sub

The LoadList is a public function that loads a list of courses into a
ListBox based on the Department_ID. Everything works as planned Fredg. Thank
you for replying and giving your feedback on this one :-)

-AKA


fredg said:
Hi again,

Is there way to capture the value in the OnClick event for a label. I want
to be able to perform an action if a user clicks on a label named
"lblAdmin_Click()".

I get error messages when trying these references:

Me.lblAdmin.Value
Me.lblAdmin_Click.Value
Forms!StudentProfile!lblAdmin.Value

Please advise on what's wrong and what I can do.

-AKA

Labels which are attached to a text control do not have any events.
Labels which are not attached to a text control do have events, so you
can write an [Event Procedure] in the click event of a label.

I haven't a clue as to what it is you are trying to accomplish by
clicking on a label, so I'll quit while I'm ahead. :-)
 
Back
Top