How To Set A Variable Like [acc] From Another Query?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • byb3
    New Member
    • Jan 2007
    • 2

    How To Set A Variable Like [acc] From Another Query?

    Hi, this is literally driving me mad, to me it seems the simplest thing in the world to do but I have found absolutely no way of doing it.

    Simply put I have a query which i'll call Query1 where it asks for input in the form:

    [ACC]

    I also have another query that uses Query1 for its information. How ON EARTH do I pass a variable to Query1 for [ACC]. It pops up with a textbox everytime but I don't want that, I want it to be filled in automatically with a value I give it. Something simple like [ACC]="RB123456" but nooooooo that does nothing.

    I have absolutely no idea how to continue. I've literally been looking how to do this for the past 2 hours. Some advice please.

    TIA
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    Originally posted by byb3
    Hi, this is literally driving me mad, to me it seems the simplest thing in the world to do but I have found absolutely no way of doing it.

    Simply put I have a query which i'll call Query1 where it asks for input in the form:

    [ACC]

    I also have another query that uses Query1 for its information. How ON EARTH do I pass a variable to Query1 for [ACC]. It pops up with a textbox everytime but I don't want that, I want it to be filled in automatically with a value I give it. Something simple like [ACC]="RB123456" but nooooooo that does nothing.

    I have absolutely no idea how to continue. I've literally been looking how to do this for the past 2 hours. Some advice please.

    TIA
    You have to keep the form open that populates the [ACC] value in query1 while running query2.

    Mary

    Comment

    • byb3
      New Member
      • Jan 2007
      • 2

      #3
      Hi thanks for your reply, its much appreciated.

      The problem is I don't know how to populate the [ACC] variable. I can only put data into this variable when it pops up as an inputbox. I can't pass information to it from another query. Simply put I would like to be able to set the [ACC] variable in query2 to a value say 'RB123456', which would then be sent to query1, without the inputbox popping up.

      The way the database is set up, I have a query which takes information from a very large database of billions of records. I then run a second query on this query. Supposedly I could merge the two queries into one but it would over complicate things and give me a giant bit of SQL code.

      How do I skip the inputbox stage and have the query fill in this box automatically. Or do I have to use a global string or another method?

      At the moment I'm not using a form but I will be eventually. How do I solve this using just a query?

      Thanks in Advance, I appreciate you spending your own time in offering your advice.

      Comment

      • willakawill
        Top Contributor
        • Oct 2006
        • 1646

        #4
        Originally posted by byb3
        Hi thanks for your reply, its much appreciated.

        The problem is I don't know how to populate the [ACC] variable. I can only put data into this variable when it pops up as an inputbox. I can't pass information to it from another query. Simply put I would like to be able to set the [ACC] variable in query2 to a value say 'RB123456', which would then be sent to query1, without the inputbox popping up.

        The way the database is set up, I have a query which takes information from a very large database of billions of records. I then run a second query on this query. Supposedly I could merge the two queries into one but it would over complicate things and give me a giant bit of SQL code.

        How do I skip the inputbox stage and have the query fill in this box automatically. Or do I have to use a global string or another method?

        At the moment I'm not using a form but I will be eventually. How do I solve this using just a query?

        Thanks in Advance, I appreciate you spending your own time in offering your advice.
        Hi. You need to post code for this. In particular we need to know both queries without abbreviating them even if you think that part of it is not relevant.

        When you are looking at query design mode go to view sql and paste the text here

        Comment

        • nico5038
          Recognized Expert Specialist
          • Nov 2006
          • 3080

          #5
          Did you try to use a subquery like:

          SELECT A.*
          FROM tblX A INNER JOIN (select B.* from tblY B where B.ID=[ACC]) ON tblA.A = B.A;

          Just replace the present queryname with "(", the SQL text from query and ")"

          Nic;o)

          Comment

          • pks00
            Recognized Expert Contributor
            • Oct 2006
            • 280

            #6
            If u have a form which takes input for ACC, how have u defined your SQL?

            Did u do [ACC] or did u reference the form?

            i.e.

            forms!nameofmyf orm!ACC

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32634

              #7
              An intriguing question - and sorry to give you more replies to respond to but,
              How are the two queries (#1 & #2) related?
              Do you want to call (refer to) #2 from within #1?
              Or maybe you want to call them one after the other from some code?
              Do you have a form from which they will both be called?
              These are important bits of information which will effect the answer as there are many possible answers depending on what the question actually is.
              I always recomment answering ALL requests for information, but I will await you response to mine :)

              Comment

              Working...