By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,592 Members | 2,005 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,592 IT Pros & Developers. It's quick & easy.

Slabwise & Pagewise Datareport

P: 41
Hi all.
In my project I am using VB6.0 & Access 2003. I want to create Slab wise & Pagewise Datareport as shown below.

Marks <30

ID Subject Marks
11 Maths 25
75 Science 18

<page Break>

Marks >30 and < 40 ' on next page
ID Subject Marks
65 Maths 38
34 Science 33
81 English 37
34 Science 35

<page break>

and so on for slabs 40 to 50, 50 to 60, 60 to 70....

Please give me hint or sample code if possibe. Give code for DataReport as I dont have Crystal Report.
Thanks
Nov 29 '07 #1
Share this Question
Share on Google+
6 Replies


Dököll
Expert 100+
P: 2,364
Hi all.
In my project I am using VB6.0 & Access 2003. I want to create Slab wise & Pagewise Datareport as shown below.

Marks <30

ID Subject Marks
11 Maths 25
75 Science 18

<page Break>

Marks >30 and < 40 ' on next page
ID Subject Marks
65 Maths 38
34 Science 33
81 English 37
34 Science 35

<page break>

and so on for slabs 40 to 50, 50 to 60, 60 to 70....

Please give me hint or sample code if possibe. Give code for DataReport as I dont have Crystal Report.
Thanks
I searched but could not find anything on this for you. Do stay tuned nonetheless in case other experts have an idea.

The Data reports I am used to aren't that fancy (Data Environ,DataReport), so no joy there;-)

Have a great week-end!

Dököll
Nov 30 '07 #2

P: 41
Thanx Dököll,
But i can not enjoy my weekend without solution of this problem. Can anybody else help me?

Thanks.
Dec 2 '07 #3

9815402440
100+
P: 180
hi
use following code for the purspose

Dim rst As New ADODB.Recordset
'MakeRecordSet is a function that i use to opens recordset. if you need its code, please ask me.
Set rst = MakeRecordSet("shape {select * from Table1} as rsAlias append new adbstr key")
With rst
.MoveFirst
While Not .EOF
' all slabs that falls in 0 - 30, value of "Key" is "0-30"
' all slabs that falls in 30-40, value of "Key" is "30-40"
' and so on
' so check for slabs and give value to "Key" accordingly


if fallsin("0-30") then
.Fields("Key").Value = "0-30"
else
.Fields("Key").Value = ""
endif
.MoveNext
Wend
End With
Dim strGrp As String
strGrp = "AS GroupedData COMPUTE GroupedData,Count(GroupedData.'Fld1') AS CountOfFld1 BY 'fld1'"
Dim rstGrouped As New ADODB.Recordset
rstGrouped.Open "Shape rsAlias " & strGrp, cn '(cn is connection)
'bind and show report as follows

With DataReport1
Set .DataSource = rstGrouped
.DataMember = ""
With .Sections("GroupHeader").Controls
.Item("key").DataMember = ""
.Item("key").DataField = "key"
End With
With .Sections("Detail").Controls
.Item("fld1").DataMember = "GroupedData"
.Item("flde").DataField = "fld1"

.Item("fld2").DataMember = "GroupedData"
.Item("fld2").DataField = "fld2"
End With
.Refresh
.Show
End With

this code is just to suggest logic or usage. please check for errors.

regards
manpreet singh dhillon hoshiarpur
Dec 3 '07 #4

P: 41
Thanks lot for your code. But ya i require code for function maketable. Also i am not familiar with keyword 'shape'. Will it work with Access?.
Thanks again for your help.

Neelesh.
Dec 3 '07 #5

9815402440
100+
P: 180
hi

following is the code for MakeRecordset function


Private Function MakeRecordset(qry As String) As ADODB.Recordset
Dim cn As New ADODB.Connection
With cn
.Provider = "MsDataShape"
.Properties("Data Provider") = "Microsoft.Jet.OLEDB.4.0"
.Properties("Data Source") = App.Path & "\data.mdb"
.Open
End With

Dim rst As New ADODB.Recordset
rst.Open qry, cn
Set MakeRecordset = rst
Set rst = Nothing
End Function

Shape clause works with ms access also.
regards
manpreet singh dhillon hoshiarpur
Dec 6 '07 #6

P: 41
Thanks a lot Manpreet.


Neelesh
Dec 8 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.