Register Free Newsletter Plus Membership
  • Home
    • Newsletters/Alerts
    • Forums
    • About
    • MS-DEFCON System
    • Master Patch List
    • Register
    • Login
Microsoft Patch Defense Condition level 4 There are isolated problems with current patches, but they are well-known and documented on this site.
SIGN IN Not a member? REGISTER PLUS MEMBERSHIP
  • Visual Basic help (Access 2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Visual Basic help (Access 2000)

    • This topic has 3 replies, 3 voices, and was last updated 22 years, 7 months ago.
    Author
    Topic
    New Reply
    WSaral
    AskWoody Lounger
    October 22, 2002 at 11:45 am #378300

    Is it possible to construct a function of substracting from 2 queries with the help of Visal Basic, instead of making three queries?

    I have to substract the liters from 2 queries and obtain the liters in a third query.The first query has input data and the second query output data.
    By substracting them i obtain the balance in the warehouse.
    I have done this by means of three queries.However i lack the flexibility,since i have to make a lot of queries for each separate case, i need to make it also for 15 other cities.

    My task is to substract the liters from the 2 queries:

    First query, called Inparis
    SELECT

    • Donate!

      Donate

      Recommended subscription price: $12.00
      Set Price

    • Extend Your Membership

      Extend Your Membership

      Set Price

    • Free Month of the AskWoody Plus Subscription

      Free Month of the AskWoody Plus Subscription

      $0.00 for 1 month
      Sign Up Now

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    .[Productid],

    • Donate!

      Donate

      Recommended subscription price: $12.00
      Set Price

    • Extend Your Membership

      Extend Your Membership

      Set Price

    • Free Month of the AskWoody Plus Subscription

      Free Month of the AskWoody Plus Subscription

      $0.00 for 1 month
      Sign Up Now

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    .[grade], Sum([order details].[liters]) AS SumOfliters
    FROM (orders INNER JOIN customers ON [orders].[customerid]=[customers].[Customerid]) INNER JOIN ([order details] INNER JOIN products ON [order

    details].[ProductID]=

    • Donate!

      Donate

      Recommended subscription price: $12.00
      Set Price

    • Extend Your Membership

      Extend Your Membership

      Set Price

    • Free Month of the AskWoody Plus Subscription

      Free Month of the AskWoody Plus Subscription

      $0.00 for 1 month
      Sign Up Now

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    .[Productid]) ON [orders].[orderid]=[order details].[OrderID]
    WHERE ((([orders].[orderdate])>#1/1/2002#))
    GROUP BY

    • Donate!

      Donate

      Recommended subscription price: $12.00
      Set Price

    • Extend Your Membership

      Extend Your Membership

      Set Price

    • Free Month of the AskWoody Plus Subscription

      Free Month of the AskWoody Plus Subscription

      $0.00 for 1 month
      Sign Up Now

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    .[Productid],

    • Donate!

      Donate

      Recommended subscription price: $12.00
      Set Price

    • Extend Your Membership

      Extend Your Membership

      Set Price

    • Free Month of the AskWoody Plus Subscription

      Free Month of the AskWoody Plus Subscription

      $0.00 for 1 month
      Sign Up Now

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    .[grade], [orders].[customerid]
    HAVING (((orders.customerid)=118))
    ORDER BY

    • Donate!

      Donate

      Recommended subscription price: $12.00
      Set Price

    • Extend Your Membership

      Extend Your Membership

      Set Price

    • Free Month of the AskWoody Plus Subscription

      Free Month of the AskWoody Plus Subscription

      $0.00 for 1 month
      Sign Up Now

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    .[grade];

    Second query called OutParis
    SELECT

    • Donate!

      Donate

      Recommended subscription price: $12.00
      Set Price

    • Extend Your Membership

      Extend Your Membership

      Set Price

    • Free Month of the AskWoody Plus Subscription

      Free Month of the AskWoody Plus Subscription

      $0.00 for 1 month
      Sign Up Now

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    .[Productid],

    • Donate!

      Donate

      Recommended subscription price: $12.00
      Set Price

    • Extend Your Membership

      Extend Your Membership

      Set Price

    • Free Month of the AskWoody Plus Subscription

      Free Month of the AskWoody Plus Subscription

      $0.00 for 1 month
      Sign Up Now

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    .[grade], Sum([order details].[liters]) AS [:SumOfliters]
    FROM (orders INNER JOIN customers ON [orders].[customerid]=[customers].[Customerid]) INNER JOIN ([order details] INNER JOIN products ON [order

    details].[ProductID]=

    • Donate!

      Donate

      Recommended subscription price: $12.00
      Set Price

    • Extend Your Membership

      Extend Your Membership

      Set Price

    • Free Month of the AskWoody Plus Subscription

      Free Month of the AskWoody Plus Subscription

      $0.00 for 1 month
      Sign Up Now

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    .[Productid]) ON [orders].[orderid]=[order details].[OrderID]
    WHERE ((([customers].[afid])=1) And (([customers].[Customerid])118))
    GROUP BY

    • Donate!

      Donate

      Recommended subscription price: $12.00
      Set Price

    • Extend Your Membership

      Extend Your Membership

      Set Price

    • Free Month of the AskWoody Plus Subscription

      Free Month of the AskWoody Plus Subscription

      $0.00 for 1 month
      Sign Up Now

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    .[Productid],

    • Donate!

      Donate

      Recommended subscription price: $12.00
      Set Price

    • Extend Your Membership

      Extend Your Membership

      Set Price

    • Free Month of the AskWoody Plus Subscription

      Free Month of the AskWoody Plus Subscription

      $0.00 for 1 month
      Sign Up Now

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    .[grade]
    ORDER BY

    • Donate!

      Donate

      Recommended subscription price: $12.00
      Set Price

    • Extend Your Membership

      Extend Your Membership

      Set Price

    • Free Month of the AskWoody Plus Subscription

      Free Month of the AskWoody Plus Subscription

      $0.00 for 1 month
      Sign Up Now

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    • JOIN TODAY!

      JOIN TODAY!

      Set Price

    .[grade];

    The thrid query:

    SELECT [InParis].[Productid], [InParis].[grade], Sum([InParis].[SumOfliters]) AS Input, Sum([OutParis].SumOfliters) AS Output,

    Sum([InParis.SumOfliters]-[OutParis.SumOfliters]) AS Balance
    FROM InParis INNER JOIN OutParis ON [InParis].[Productid]=[OutParis].[Productid]
    GROUP BY [InParis].[Productid], [InParis].[grade];

    I need a function something like that

    Dim SQLIn As String
    Dim SQLOut As String

    SQLIn = ……….
    SQLOut = ……….

    And then: somehow to substract with Run SQL:
    Sum([order details].[liters]) AS [:SumOfliters] from the SQLIn – Sum([order details].[liters]) AS [:SumOfliters] from the SQLOut = ??

    Any help with this difficult and i am afraid not well described by me problem ?

    Reply | Quote
    Viewing 0 reply threads
    Author
    Replies
    • WSHansV
      AskWoody Lounger
      October 22, 2002 at 12:12 pm #625753

      I assume that the 118 is the ID for one of the cities (customers?). You can replace this with a parameter. This can be an interactive parameter (to be filled in manually each time the queries are run) or the value of a control on a form (or report). Perhaps, you don’t need VBA if you use a parameter.

      An interactive parameter looks like [Enter CustomerID]
      A reference to a control on a form looks like [Forms]![frmMyForm]![txtCustomerID] where frmMyForm is the name of the form and txtCustomerID the name of the control.

      Reply | Quote
      • WSaral
        AskWoody Lounger
        October 22, 2002 at 12:43 pm #625763

        Thank you for your reply.Yes, i will use a parameter later on, but my problem is substracting from 2 queries.For say customer Nr 118, i have 2 queries
        which are differennt.I want to substract the liters from the 2 queries.I can do it with three queries,but i woulld like to use VBA in order to make things more flexible,use parameters,etc.Can you help me further?If you look at my thrid query,you will see it is based on the previous 2 queries.i want to aoid the use of three queries,if possble.Actually the thrid query only substracts the quantity from the 1 st query and the 2nd query.So,to make my question more clear please forget the customer,and take it to be a constant figure. If i solve the case for this customer,as you have already noted i can solve it for ther other customners too.

        Best regards

        Reply | Quote
        • WSpatt
          AskWoody Lounger
          October 22, 2002 at 7:55 pm #625855

          Why do you want to avoid using 3 queries? If 3 queries work, why fix it?
          Pat cheers

          Reply | Quote
    Viewing 0 reply threads
    Reply To: Reply #625763 in Visual Basic help (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel
DON'T MISS OUT!
Subscribe to the Free Newsletter
We promise not to spam you. Unsubscribe at any time.
Invalid email address
Thanks for subscribing!

Register
Lost your password?

Plus Membership

Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.

AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.


Get Plus!

Welcome to our unique respite from the madness.

It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.

Search Newsletters

Search Forums

Advanced Search

View the Forum

  • Recent Replies
  • My Replies
  • My Active Topics
  • New Posts in the Last day
  • Private Messages
  • Knowledge Base
  • How to use the Forums
  • All Forums
  • Search for Topics

    • Most popular topics
    • Topics with no replies
    • Recently active topics
    • New posts: Last day
    • New posts: Last three days
    • New posts: Last week
    • New posts: Last month
    • Topics with most replies
    • Latest topics

    Recent Topics

    • Windows Update orchestration platform to update all software by Alex5723
      3 hours, 28 minutes ago
    • May preview updates by Susan Bradley
      5 hours, 6 minutes ago
    • Microsoft releases KB5061977 Windows 11 24H2, Server 2025 emergency out of band by Alex5723
      5 hours, 13 minutes ago
    • Just got this pop-up page while browsing by Alex5723
      3 hours, 8 minutes ago
    • KB5058379 / KB 5061768 Failures by crown
      4 minutes ago
    • Windows 10 23H2 Good to Update to ? by jkitc
      18 hours, 15 minutes ago
    • At last – installation of 24H2 by Botswana12
      18 hours, 59 minutes ago
    • MS-DEFCON 4: As good as it gets by Susan Bradley
      1 hour, 12 minutes ago
    • RyTuneX optimize Windows 10/11 tool by Alex5723
      1 day, 7 hours ago
    • Can I just update from Win11 22H2 to 23H2? by Dave Easley
      1 day ago
    • Limited account permission error related to Windows Update by gtd12345
      1 day, 20 hours ago
    • Another test post by gtd12345
      1 day, 20 hours ago
    • Connect to someone else computer by wadeer
      1 day, 15 hours ago
    • Limit on User names? by CWBillow
      1 day, 18 hours ago
    • Choose the right apps for traveling by Peter Deegan
      1 day, 8 hours ago
    • BitLocker rears its head by Susan Bradley
      16 hours, 12 minutes ago
    • Who are you? (2025 edition) by Will Fastie
      15 hours, 9 minutes ago
    • AskWoody at the computer museum, round two by Will Fastie
      1 day, 10 hours ago
    • A smarter, simpler Firefox address bar by Alex5723
      2 days, 7 hours ago
    • Woody by Scott
      2 days, 16 hours ago
    • 24H2 has suppressed my favoured spider by Davidhs
      15 hours, 49 minutes ago
    • GeForce RTX 5060 in certain motherboards could experience blank screens by Alex5723
      3 days, 6 hours ago
    • MS Office 365 Home on MAC by MickIver
      3 days ago
    • Google’s Veo3 video generator. Before you ask: yes, everything is AI here by Alex5723
      3 days, 20 hours ago
    • Flash Drive Eject Error for Still In Use by J9438
      15 hours, 33 minutes ago
    • Windows 11 Insider Preview build 27863 released to Canary by joep517
      4 days, 15 hours ago
    • Windows 11 Insider Preview build 26120.4161 (24H2) released to BETA by joep517
      4 days, 15 hours ago
    • AI model turns to blackmail when engineers try to take it offline by Cybertooth
      3 days, 19 hours ago
    • Migrate off MS365 to Apple Products by dmt_3904
      3 days, 20 hours ago
    • Login screen icon by CWBillow
      3 days, 10 hours ago

    Recent blog posts

    • May preview updates
    • MS-DEFCON 4: As good as it gets
    • Choose the right apps for traveling
    • BitLocker rears its head
    • Who are you? (2025 edition)
    • AskWoody at the computer museum, round two
    • AI coming to everything
    • You can’t handle me

    My Profile

    Login and Registration

    • Log In
    • Register

    Key Links

    • > Computerworld's The Microsoft Patch Lady
    • > Computerworld's Woody on Windows
    • AskWoody Knowledge Base index
    • BlockaPatch tools
    • Gift subscription for Ask Woody Newsletter
    • Microsoft Answers Forum
    • Tasks for the Weekend YouTube Channel
    May 2025
    S M T W T F S
     123
    45678910
    11121314151617
    18192021222324
    25262728293031
    « Apr    

    Remembering Woody

     

    Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.

    Mastodon profile for DefConPatch
    Mastodon profile for AskWoody

     

    Home • About • FAQ • Posts & Privacy • Forums • My Account
    Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts

    Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.