Results 1 to 3 of 3

Thread: MS Access Query building for VB6

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2010
    Posts
    11

    Post MS Access Query building for VB6

    I am using vb6 and I have a table in access database which contains following fields --
    1) account_no
    2) account_type
    3) trans_date
    4) sequence_no
    5) deposit
    6) withdrawl
    7) balance
    At the time of first transaction of every account_no of a particular account_type, the sequence_no will be 1. Then after every transaction, the sequence_no field is incremented with 1 for each account_no of a particular account_type and balance field is also changed accordingly. There may be same sequence_no against many transactions of different account_no.

    Now, I want to build a report of the last balance of every account_no of a particular account_type i.e. where the sequence_no is maximun for every account_no.
    Can anybody help me building the query for the above purpose ? ?

  2. #2
    Junior Member
    Join Date
    Jan 2011
    Posts
    25

    Re: MS Access Query building for VB6

    You can use Access Function MAX for this purpose. For example:

    SELECT Max(Sequence_No) FROM MyTable WHERE Account_No = 9999

    Here is a link to help you out a bit more on the Max function.

    http://www.databasedev.co.uk/access_max_function.html

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2010
    Posts
    11

    Re: MS Access Query building for VB6

    Thanx for your reply.
    I know the MAX function but I need the value of BALANCE field for every account number where the sequence no. is maximum.
    something like this --
    "Select account_no, balance
    From Mydb.table1
    Where sequence_no = max(sequence_no)
    Group by account_no"
    Last edited by mitakash; Feb 1st, 2011 at 02:29 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
  •  



Click Here to Expand Forum to Full Width