Programatically returning a label number

G

Guest

I have a form that has an image as the main item on it. th image is an
exploded schematic of an appliance with parts references on it.

The problem is that I have placed labels over the parts references and on
the click event of the label the following code runs.

Private Sub Label4_Click()
On Error GoTo Err_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Part"
stLinkCriteria = "Partid =" & Me.Label4.Caption
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Click:
Exit Sub

Err_Click:
MsgBox Err.Description
Resume Exit_Click
End Sub

The caption contains the PartID
This works fine, however, the seven forms like this seem to have so much
code that the database is blowing up to 85 meg. I have used compact and the
image itself is under 250K.

What I want to try to do is to convert this to a function but have so far
been unsuccessful at being able to return the label number into the code
programatically. Each form may have up to 70 labels with events attached.


Thanks in advance.
 
D

Douglas J Steele

I'm not sure there's an easy solution to this using labels, since labels
don't show up as ActiveControl.

You could try using text boxes instead of labels (make them locked, so that
the user can't change what's in them), so that you can have a generic
function that refers to ActiveControl.

To use a same generic function for the Click event for a number of controls,
select each of the controls, then look at the properties. Put
=FunctionName() in the OnClick property box. Make sure you put the () after
the function name. (And yes, it must be a function, not a sub, even if it
doesn't return anything)
 
D

Dirk Goldgar

Biz Enhancer said:
I have a form that has an image as the main item on it. th image is an
exploded schematic of an appliance with parts references on it.

The problem is that I have placed labels over the parts references
and on the click event of the label the following code runs.

Private Sub Label4_Click()
On Error GoTo Err_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Part"
stLinkCriteria = "Partid =" & Me.Label4.Caption
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Click:
Exit Sub

Err_Click:
MsgBox Err.Description
Resume Exit_Click
End Sub

The caption contains the PartID
This works fine, however, the seven forms like this seem to have so
much code that the database is blowing up to 85 meg. I have used
compact and the image itself is under 250K.

What I want to try to do is to convert this to a function but have so
far been unsuccessful at being able to return the label number into
the code programatically. Each form may have up to 70 labels with
events attached.

What about using transparent command buttons instead of labels? Labels
can't receive the focus, and so can't be the ActiveControl; but command
buttons can, even if their Transparent property is set to True.
 
G

Guest

Thanks Doug.

I opted to use a label because the textbox had two issues.
1. The blinking cursor
2. Setting transperancy for the backstyle is fine until the textbox gains
focus. It then covers the drawing on the image that I want the user to click
on to get detail. Kind of loses the user when that happens.

Dirk's suggestion is good with the exception that I need to assign a value
to the control that the user activates. So far I am unable to see how to
assign a value to a command button anywhere other than in VB.

And here was I thinking I was so clever to create these 'hotspots' on the
form!

I may just have to accept the fat frontend.

Thanks for your help.

Nick.
 
G

Guest

Solved the fat frontend now. The problem was embedding the image. Linking
them has reduced the frontend by over 55Mb. Still don't know why an image
that is less than 250Kb on disc can blow up over 7Mb when embedded in a form.
 

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