|
-
Sep 7th, 2005, 08:24 AM
#1
Thread Starter
New Member
Help newnie: using grouping and select at the same time
Hi,
I have data in an access database that I wish to output in a VB6 report
depending on certaine dates (if a record data_field is not in the range, it
should be excluded)
Imanaged to do that by writing the code (see below) by hand (or using a stored procedure).
However, I also want to use the grouping feature of VB6 which I cannot get
to work with the above code as only detail section accepts information.
Is there a way to get both to work ?
VB Code:
Private Sub mnureport_Click()
Dim cn As Connection
Dim rs As Recordset
Dim dv1 As Variant
Dim dv2 As Variant
Set cn = New Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and
Settings\Administrator\Desktop\TobaccoCardPerso\TCP.mdb;Persist Security
Info=False"
dv1 = DateValue("05/10/2003")
dv2 = DateValue("05/20/2006")
Set rs = cn.Execute("SELECT * from TCP WHERE Date BETWEEN #" & dv1 & "#
AND #" & dv2 & "# ORDER By last_name")
Set DataReport1.DataSource = rs
DataReport1.Show
End Sub
Regards,
Philipe
Edit: Added [vbcode][/vbcode] tags for clairty. - Hack
Last edited by Hack; Sep 7th, 2005 at 08:32 AM.
-
Sep 7th, 2005, 08:35 AM
#2
Re: Help newnie: using grouping and select at the same time
Welcome to the forums. 
Date is a reserved word and should not be used as DB table or field names (nor should any other reserved word)
When you use a reserved word as a field name, you must use brackets to encapsulate the name, so "...WHERE date" needs to be "...WHERE [date]"
Other than that, you didn't state what issues you were having with this code.
(Also, as indicated in my signature, when posting code you should use the vbcode tags as it makes reading the code much easier.)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|