Re: Programatically returning a label number



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)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Biz Enhancer" <BizEnhancer@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E5677513-B1DA-4CF5-AB97-EF4FB27CF41C@xxxxxxxxxxxxxxxx
> 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.


.



Relevant Pages

  • Re: How to avoid MouseEvent recursion?
    ... a number of folks suggest I handle this by placing labels ... picture box to fire *only* when I'm physically moving the mouse cursor. ... Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As ... Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ...
    (microsoft.public.vb.general.discussion)
  • Re: Cannot save Form changes with VBA
    ... If the form and textbox are bound to a field in a table then the ... Private Sub Form_Load ... I use labels on the form to record which file was last loaded. ... Public Function adhIsFormOpenAs Boolean ...
    (comp.databases.ms-access)
  • Re: Problems with charts, VBA and series...
    ... Here's a format that will use the first row as series labels and the ... and blank cell, and make your chart. ... Sub SeriesNameAssigner() ... Dim oSrs As Series ...
    (microsoft.public.excel.charting)
  • Re: Userform SetFocus with Exit and Cancel
    ... The labels look like textboxes with a grey background. ... >> Private Sub CommandButton1_Click ... >> Private Sub SymbolBox_Exit(ByVal cancel As MSForms.ReturnBoolean) ... >> Dave Peterson ...
    (microsoft.public.excel.programming)
  • Re: Edit - Save Buttons on Form - OnClick "not working"?
    ... Private Sub btnEdit_Click ... HOWEVER - well, yes, they ARE LABELS. ... change the Visible property of these "buttons" so that EDIT was visible ... Private Sub SaveButton_Click ...
    (microsoft.public.access.formscoding)