|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > using group headers in data reports |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|