-
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?
-
Re: SQL command and vb6
where date = thisdate or date = thatdate
Good Luck
-
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.
-
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.
-
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.
-
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?
-
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.
-
Re: SQL command and vb6
why show this msg:
"compile error:
argument not optional"
-
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.