Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

public declared variable used in a query?

Discussion in 'Information Technology' started by tsison7, Jul 28, 2006.

  1. tsison7

    tsison7
    Expand Collapse
    Guest

    I capture the userID in my login startup form. I then set it = to a publicly
    declared variable currentuserID. I tried to use the currentuserID in a query
    but I get an error.

    In my query I have under userID
    = currentuserID
    Access automatically puts quotations around it as follows
    = "currentuserID"
    and I get a type mismatch error.

    What am I doing wrong?
    --
    TIA
     
  2. Loading...


  3. Jeff Boyce

    Jeff Boyce
    Expand Collapse
    Guest

    Create a function that returns that public variable. Call the function in
    your query.

    Regards

    Jeff Boyce
    Microsoft Office/Access MVP

    "tsison7" <tsison7@discussions.microsoft.com> wrote in message
    news:C8D3A043-5D8B-411B-95F6-7AC17968AC94@microsoft.com...
    >I capture the userID in my login startup form. I then set it = to a
    >publicly
    > declared variable currentuserID. I tried to use the currentuserID in a
    > query
    > but I get an error.
    >
    > In my query I have under userID
    > = currentuserID
    > Access automatically puts quotations around it as follows
    > = "currentuserID"
    > and I get a type mismatch error.
    >
    > What am I doing wrong?
    > --
    > TIA
     
  4. RoyVidar

    RoyVidar
    Expand Collapse
    Guest

    tsison7 wrote in message
    <C8D3A043-5D8B-411B-95F6-7AC17968AC94@microsoft.com> :
    > I capture the userID in my login startup form. I then set it = to a
    > publicly declared variable currentuserID. I tried to use the
    > currentuserID in a query but I get an error.
    >
    > In my query I have under userID
    > = currentuserID
    > Access automatically puts quotations around it as follows
    > = "currentuserID"
    > and I get a type mismatch error.
    >
    > What am I doing wrong?


    I gave the below answer to similar question earlier today

    "Not directly, but through a public function residing also in a
    standard
    module.

    public function GetMyVariable() as <your data type>
    GetMyVariable = g_MyPublicVariable
    end function

    Then refer to that function both in the query and report. Note again,
    that the function must reside in a standard module, not a forms/reports
    module."

    --
    Roy-Vidar
     

Share This Page