Results 1 to 6 of 6
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Reference Form Name In Global Var In Query? (a2k (9.0.3821) SR-1 Jet 4.0)

    Reference Form Name In Global Var In Query?
    a2k (9.0.3821) SR-1 Jet 4.0

    I have tho following code in a form that sets the form name up as a global variable

    gloSetValue "ParentFormName", Me.Name ' set global variable with this forms name

    How do I reference a field on the form in a query with a global variable?

    I

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Reference Form Name In Global Var In Query? (a2k (9.0.3821) SR-1 Jet 4

    John,

    You will need to create a function that returns the value of the global variable, something like this :
    GetGloValue ("ParentFormName")
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reference Form Name In Global Var In Query? (a2k (9.0.3821) SR-1 Jet 4

    Hi Mark

    I have the function as described in previous post

    I

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Reference Form Name In Global Var In Query? (a2k (9.0.3821) SR-1 Jet 4

    John,

    I don't think you can do it that way. There are two possibilities:
    <UL><LI>Define a function that returns the value of [Forms]![frm_PP_ACD]![PermitType], for example

    Function GetControlValue(FormVarName As String, ControlVarName As String)
    GetControlValue = Forms(gloGetValue(FormVarName)).Controls(gloGetVal ue(ControlVarName))
    End Function

    Use it like GetControlValue("ParentFormName", "ParentFormControlName")
    <LI>Construct the SQL in code and substitute the appropriate value. You can then use this SQL the way you need, for instance, set the SQL of a stored query to this SQL, or open a recordset on it, or ...[/list]

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reference Form Name In Global Var In Query? (a2k (9.0.3821) SR-1 Jet 4

    Hi Hans

    The second method did it for me. I will library both methods for future use.

    What is the best way to see the current value of an global variable for degugging purposes?

    Thanks, John

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Reference Form Name In Global Var In Query? (a2k (9.0.3821) SR-1 Jet 4

    Hello John,

    I don't know if there is a single "best" way to see the value of a variable, expression or control. You can
    <UL><LI>Set a breakpoint (Debug | Toggle Breakpoint); once the code is paused, hover the mouse over the variable.
    <LI>Add a watch expression (Debug | Add Watch... or Debug | Quick Watch...)
    <LI>Temporarily insert MsgBox statements in your code.
    <LI>Temporarily insert Debug.Print statements in your code.
    <LI>For long-term debugging: insert code to write the value of the variable to a table or to a text file, together with other relevant information.[/list]Which one is to be preferred, depends on the situation.

Posting Permissions

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