Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 28th, 2003, 05:51 AM
fergo fergo is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 4 fergo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
using group headers in data reports

hello

im having problems creating a data report in vb 6.0 with a group header. ive created a program to make shopping lists. there are items within categories. to print off the list im using data reports. because you dont have to save a list to print it, im trying to set the datasource to the report to a record set created in memory.

so this is how i want the report to look like:

Category 1

Item 1 Item 2
Item 3 Item 4

to get the items in two columns, ive got 2 textboxes in the data report: ItemOdd and ItemEven.

now what makes this report complicated is that every category isnt neccessarily being used. ie if your list is only using 3 out of 11 categories, you only want the 3 categories being shown. this is what I made:

Private Sub cmdPrint_Click()

Dim rsList As New ADODB.Recordset
Dim rsCategory As New ADODB.Recordset
Dim oItem As clsItem
Dim oCategory As clsCategory
Dim dListItems As Double
Dim i As Integer
Dim j As Integer
Dim k As Integer

With rsList
.Fields.Append ("ItemOdd"), adVarChar, 70
.Fields.Append ("ItemEven"), adVarChar, 70
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open
End With

With rsCategory
.Fields.Append ("CatName"), adVarChar, 40
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open
End With

Set oItem = New clsItem

If miArrayIndex > 0 Then

'goCategories is an object of clsCategory. It holds all category data
For i = LBound(goCategories) To UBound(goCategories)

If itemInCategory(goCategories(i).ID) Then

rsCategory.AddNew
rsCategory!CatName = goCategories(i).CatName
rsCategory.Update

j = 0
k = 1

'moListItems holds all the relationship data for a many-to-many relationship. ie it holds the list id, item id and quantity id. if its a new list, the id is set default to 'NEW_ID'.
Do Until j = UBound(moListItems)

If oItem.findCatID(moListItems(j).ItemID) = goCategories(i).ID Then

rsList.AddNew
rsList!ItemOdd = moListItems(j).Quantity & " x " & oItem.findItemName(moListItems(j).ItemID)

If UBound(moListItems) > j Then
rsList!ItemEven = moListItems(k).Quantity & " x " & oItem.findItemName(moListItems(k).ItemID)
End If

rsList.Update

End If

j = j + 1
k = k + 1

Loop

Set drList.DataSource = rsCategory
drList.DataMember = ""

drList.Sections("Header").Controls.Item("txtCategory").DataField = "CatName"
drList.Sections("Header").Controls.Item("txtCategory").DataMember = "rsCategory"

With drList.Sections("Detail").Controls
.Item("txtOdd").DataField = "ItemOdd"
.Item("txtOdd").DataMember = "rsList"
.Item("txtEven").DataField = "ItemEven"
.Item("txtEven").DataMember = "rsList"
End With

End If

Next

drList.WindowState = vbMaximized
drList.Show vbModal, Me

Else
MsgBox "You must have at least one item in your list to print"
End If

End Sub

i get an error saying "DataField 'rsCategory.CatName' not found". i have no idea what to do from here. any assistance would be great. if my explanation isnt good enough, feel free to ask me questions.

thanks

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > using group headers in data reports


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT