Get values from Access Query thru VB


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Get values from Access Query thru VB

  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, 01:45 PM
  2. Replies: 60
    Last Post: 09-13-2002, 06:41 PM
  3. Access 97 to 2000 Conversion Error
    By Michelle in forum VB Classic
    Replies: 8
    Last Post: 04-19-2002, 06:01 PM
  4. Replies: 1
    Last Post: 04-02-2002, 08: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, 11:36 AM

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


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center