Run code by clicking on a label - Not working

S

Silvio

The code below works just fine when used with a command button (continuous
form) in order to open a second Form (Single Record) to see all the details
for the selected record only. However, instead of using a command button, I
am trying to use it LABEL (OnClick event) to produce an underlined web like
effect. However, the details form, always shows data from the first record in
my list (continuous form). I appear that command buttons and a label handle
the same codes differently. A bleak-point in the code shows that the MyID
always refers to the first record instead of the record ID of the record
being selected. How can I fix this?


Dim MyID As Integer
MyID = [ViolationID]
Forms![frmMenu]![SubItems2].Form.Filter = "[ViolationID] = " & MyID
Forms![frmMenu]![SubItems2].Form.FilterOn = True


Thank you,
Silvio
 
D

Dirk Goldgar

Silvio said:
The code below works just fine when used with a command button (continuous
form) in order to open a second Form (Single Record) to see all the
details
for the selected record only. However, instead of using a command button,
I
am trying to use it LABEL (OnClick event) to produce an underlined web
like
effect. However, the details form, always shows data from the first record
in
my list (continuous form). I appear that command buttons and a label
handle
the same codes differently. A bleak-point in the code shows that the MyID
always refers to the first record instead of the record ID of the record
being selected. How can I fix this?


Dim MyID As Integer
MyID = [ViolationID]
Forms![frmMenu]![SubItems2].Form.Filter = "[ViolationID] = " & MyID
Forms![frmMenu]![SubItems2].Form.FilterOn = True


The problem is that a label can't receive the focus, so clicking on the
label for a particular record won't make that record become current. If you
can't format a command button to look the way you want, I think you could
put a *transparent* command button on top of the label, and use the Click
event of that command button instead of the label. Command buttons have a
Transparent property, on the Format tab of the button's property sheet in
design view.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top