Register Free Newsletter Plus Membership
  • Home
    • Newsletters/Alerts
    • Forums
    • About
    • MS-DEFCON System
    • Master Patch List
    • Register
    • Login
Microsoft Patch Defense Condition level 2 Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it.
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: 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

    • InfoStealer Malware Data Breach Exposed 184 Million Logins and Passwords by Alex5723
      4 hours, 35 minutes ago
    • How well does your browser block trackers? by n0ads
      1 minute ago
    • You can’t handle me by Susan Bradley
      1 hour, 13 minutes ago
    • Chrome Can Now Change Your Weak Passwords for You by Alex5723
      15 minutes ago
    • Microsoft: Over 394,000 Windows PCs infected by Lumma malware, affects Chrome.. by Alex5723
      15 hours, 58 minutes ago
    • Signal vs Microsoft’s Recall ; By Default, Signal Doesn’t Recall by Alex5723
      3 hours, 31 minutes ago
    • Internet Archive : This is where all of The Internet is stored by Alex5723
      16 hours, 22 minutes ago
    • iPhone 7 Plus and the iPhone 8 on Vantage list by Alex5723
      16 hours, 27 minutes ago
    • Lumma malware takedown by EyesOnWindows
      4 hours, 43 minutes ago
    • “kill switches” found in Chinese made power inverters by Alex5723
      1 day, 1 hour ago
    • Windows 11 – InControl vs pausing Windows updates by Kathy Stevens
      1 day, 1 hour ago
    • Meet Gemini in Chrome by Alex5723
      1 day, 5 hours ago
    • DuckDuckGo’s Duck.ai added GPT-4o mini by Alex5723
      1 day, 5 hours ago
    • Trump signs Take It Down Act by Alex5723
      1 day, 13 hours ago
    • Do you have a maintenance window? by Susan Bradley
      19 minutes ago
    • Freshly discovered bug in OpenPGP.js undermines whole point of encrypted comms by Nibbled To Death By Ducks
      15 hours, 34 minutes ago
    • Cox Communications and Charter Communications to merge by not so anon
      1 day, 16 hours ago
    • Help with WD usb driver on Windows 11 by Tex265
      1 hour, 3 minutes ago
    • hibernate activation by e_belmont
      2 days, 1 hour ago
    • Red Hat Enterprise Linux 10 with AI assistant by Alex5723
      2 days, 5 hours ago
    • Windows 11 Insider Preview build 26200.5603 released to DEV by joep517
      2 days, 8 hours ago
    • Windows 11 Insider Preview build 26120.4151 (24H2) released to BETA by joep517
      2 days, 8 hours ago
    • Fixing Windows 24H2 failed KB5058411 install by Alex5723
      1 day, 4 hours ago
    • Out of band for Windows 10 by Susan Bradley
      2 days, 13 hours ago
    • Giving UniGetUi a test run. by RetiredGeek
      2 days, 20 hours ago
    • Windows 11 Insider Preview Build 26100.4188 (24H2) released to Release Preview by joep517
      3 days, 3 hours ago
    • Microsoft is now putting quantum encryption in Windows builds by Alex5723
      23 hours, 35 minutes ago
    • Auto Time Zone Adjustment by wadeer
      3 days, 8 hours ago
    • To download Win 11 Pro 23H2 ISO. by Eddieloh
      3 days, 5 hours ago
    • Manage your browsing experience with Edge by Mary Branscombe
      5 hours, 51 minutes ago

    Recent blog posts

    • You can’t handle me
    • Do you have a maintenance window?
    • Out of band for Windows 10
    • Manage your browsing experience with Edge
    • Fewer vulnerabilities, larger updates
    • Hobbies — There’s free software for that!
    • Apps included with macOS
    • Kevin Beaumont on Microsoft Recall

    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.

        Notifications

        #