Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2007
    Posts
    74

    Unanswered: Referencing a form using a variable?

    I have a piece of code that I want to be able to call from several different forms when the On Current event is triggered. I am trying to store the name of the form calling the code in a varible and then use the variable


    On Current Event

    Code:
     
     
    Private Sub Form_Current()
    Dim FormName As String
     
    '***Call OLEDisplay
    FormName = Me.Form.name
    Call Feedback_Viewer_Utilities.OLEDisplay(FormName)
     
    End Sub

    Generic code being called

    Code:
     
     
    Function OLEDisplay(FormName As String)
    On Error GoTo ErrHand
     
    If FormName.OLEFile.LpOleObject <> 0 Then
        FormName.OLEFile.Visible = True
        End
    End If
     
    ErrHand:
    'If we are here there is no OLE File for the row. So we do not need to display the object.
    FormName.OLEFile.Visible = False
     
    End Function

    I get an error when I try to compile that says "Invalid Qualifier". Is it possible to do what I am attempting to do?

  2. #2
    Join Date
    Jun 2007
    Posts
    74

    Solved.

    Sorry to bother.... I found the answer..

    Instead of saying:
    Foms.variablename.control

    I used:
    Forms(variablename).control

    and it works...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •