Results 1 to 9 of 9

Thread: SQL command and vb6

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Location
    Dhaka, Bangladesh
    Posts
    222

    SQL command and vb6

    In my access file I write code in query
    Code:
    SELECT AccountInfo.incategory, Sum(AccountInfo.InAmount) AS TotalAmount
    FROM AccountInfo
    WHERE (((AccountInfo.Date)>=#1/1/2009# And (AccountInfo.Date)<=#12/31/2009#))
    GROUP BY AccountInfo.incategory;
    It show the total amount between 01-01-09 to 31-12-09 and it show in report. but in vb6 I want I select this two date and the total amount will show in report. what I need to do?

  2. #2
    Frenzied Member
    Join Date
    Mar 2009
    Posts
    1,182

    Re: SQL command and vb6

    where date = thisdate or date = thatdate



    Good Luck
    Option Explicit should not be an Option!

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Location
    Dhaka, Bangladesh
    Posts
    222

    Re: SQL command and vb6

    another thing in this query date is not show. cause if I show the date then it not work. if I use your code in vb6 then how it find out the amount and category by date. cause date not show. please details.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: SQL command and vb6

    Thread moved to 'Database Development' forum (the 'VB6' forum is only meant for questions which don't fit in more specific forums)

    I think you should be the one to give more details - because I don't actually know what you are trying to do, or which part(s) of it you are having a problem with.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Location
    Dhaka, Bangladesh
    Posts
    222

    Re: SQL command and vb6

    I made a query in access. here three field. Incategory, INamount, date. and I write code what I write above. here I write date. so the data show between this date. I want I select this date from vb6 not from access and the data show in vb6.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Location
    Dhaka, Bangladesh
    Posts
    222

    Re: SQL command and vb6

    I write in data environment:

    Code:
    SELECT AccountInfo.incategory, Sum(AccountInfo.InAmount) AS SumOfInAmount FROM AccountInfo where Date and Date between DTFr.value and DTTo.vlaue GROUP BY AccountInfo.incategory;
    DTFr and DTTo is dtpicker. and I write code in a button for show the report is

    Code:
         Load DataEnvironment1
        With DataEnvironment1
        If .Command3.State <> 0 Then .Command3.Close
         .Command3 Format(DTFr.Value, "dd/mm/yyyy"), Format(DTTo.Value, "dd/mm/yyyy")
         End With
    datareport1.Show
    but a error msg show:
    "compile error:
    argument not optional"
    and then select this word

    Code:
        If .Command3.State <> 0 Then .Command3.Close
    now what I need to do?

  7. #7
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: SQL command and vb6

    I think you're saying that you want a user to be able to select their own dates, rather than hard coding them into your sql string, is that right?

    If so you just need to put a pair of datepickers onto a form and use their values as parameters when issuing your sql statement. The ADO tutorials at the top of the forum will show you exactly how to do this.
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Location
    Dhaka, Bangladesh
    Posts
    222

    Re: SQL command and vb6

    why show this msg:
    "compile error:
    argument not optional"

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: SQL command and vb6

    That is one of the errors covered by the article What does this error mean, and how do I fix it? from our Classic VB FAQs (in the FAQ forum)

    If you want more help than that, you'll need to give us more details - such as which line the error occurred on, etc.

Tags for this Thread

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