Welcome to SPN

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

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

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
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page