DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Posts
    52

    Get values from Access Query thru VB

    I have a query called “QueryTot” which calculates the sum of fields and I am trying to store the values to variables thru the following code, but I am getting the values as null.

    Dim Dbs As Database
    Dim Tot As Recordset
    Dim strSqlTot as string


    strSqlTot = SELECT Sum(QueryTot.Bal1) AS SumOfBal1, Sum(QueryTot.Bal2) AS SumOfBal2, Sum(QueryTot.Bal3) AS SumOfBal3 FROM QueryTot;

    Set Tot = Dbs.OpenRecordset(strSqlTot)

    Value1 = MrTotal.Fields(SumOfBal1)
    Value2 = MrTotal.Fields(SumOfBal2)
    Value3 = MrTotal.Fields(SumOfBal3)

    How do I get the sum to the variables Value1, Value2, Value3?

    Thanks in advance,
    Sinni.

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    What is "MrTotal"? I would think you'd want to do:

    Value1 = Tot.Fields("SumOfBal1")
    Value2 = Tot.Fields("SumOfBal2")
    Value3 = Tot.Fields("SumOfBal3")
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Dec 2003
    Posts
    52
    I am sorry I made a typo, I have the code as

    Value1 = Tot.Fields("SumOfBal1")
    Value2 = Tot.Fields("SumOfBal2")
    Value3 = Tot.Fields("SumOfBal3")

    but still I get the value as null

Similar Threads

  1. SQL Connectivity with Linked MS Access DB
    By David Croft in forum Database
    Replies: 0
    Last Post: 08-13-2003, 12:45 PM
  2. Replies: 60
    Last Post: 09-13-2002, 05:41 PM
  3. Access 97 to 2000 Conversion Error
    By Michelle in forum VB Classic
    Replies: 8
    Last Post: 04-19-2002, 05:01 PM
  4. Replies: 1
    Last Post: 04-02-2002, 07:32 AM
  5. Access 2000 --> Access 97 using VB?
    By Paul Shaddick paul.shaddick in forum VB Classic
    Replies: 0
    Last Post: 09-24-2000, 10:36 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links