VB Data Report Detail line

VB Data Report Detail line

Post by Andy » Mon, 24 Nov 2003 16:03:21


I have multiple rows in a record set and am having trouble getting them
all in the detail section. I am getting the correct number of rows for
the set, but I am repeatedly getting the first row always. Can I do it
manually? If so how? I am using labels in the detail section not text
boxes, does that make a difference? Heres the code if anyone wants to
see it:


Option Explicit
'*************************************************************
' The following is a Textbook Evaluation Report BY COURSE ID *
'*************************************************************
Private Sub cmdReportsGenerate_Click()

' Connections
Dim EZRConnection As ADODB.Connection

' RecordSets
Dim courseInfoRecSet As ADODB.Recordset
Dim bookRecSet As ADODB.Recordset

' Variables
Dim strConn As String
Dim strPathToMDB As String
Dim courseSQL As String
Dim bookSQL As String


' Assignments
strPathToMDB = ".\ezrate.mdb"

strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strPathToMDB & ";"
Set EZRConnection = New ADODB.Connection
EZRConnection.Open strConn



' Prepare the Course Information for insertion into the report
courseSQL = "SELECT * FROM Course WHERE C_CourseId = '" &
txtInput.Text & "';"
Set courseInfoRecSet = New ADODB.Recordset
courseInfoRecSet.Open courseSQL, EZRConnection, adOpenForwardOnly, _
adLockReadOnly, adCmdText

' Retrieve the Book Details from the Book table of the current Book
being processed.
bookSQL = "SELECT B_ISBN, B_Title, B_Edition, B_Author, B_Year,
P_Name FROM Book, Publisher WHERE P_PublisherId = B_PublisherId;"
Set bookRecSet = New ADODB.Recordset
bookRecSet.Open bookSQL, EZRConnection, adOpenForwardOnly, _
adLockReadOnly, adCmdText

'**********************************************************************************
Dim Index As Integer
Dim Index2 As Integer

Index = 0
Index2 = 0


With DataReport1

' Set DataSource to nothing or the report will want to use
its own datasource.
Set .DataSource = Nothing
.DataMember = ""

Set .DataSource = courseInfoRecSet
'.Refresh

With .Sections("Section2").Controls

Do Until Index = 1
.Item("lblInput2").Caption =
courseInfoRecSet.Fields("C_CourseDescription").Value
.Item("lblInput3").Caption =
courseInfoRecSet.Fields("C_CourseId").Value
Index = Index + 1
Loop

End With
End With

With DataReport1

' Set DataSource to nothing or the report will want to use
its own datasource.
Set .DataSource = Nothing
.DataMember = ""

Set .DataSource = bookRecSet

With .Sections("Section1").Controls

.Item("Label1").Caption = bookRecSet.Fields("B_Title")
.Item("Label2").Caption = bookRecSet.Fields("B_ISBN")

End With

.Show vbModal

End With

courseInfoRecSet.Close
bookRecSet.Close

End Sub


-Andrew
 
 
 

VB Data Report Detail line

Post by Andy » Mon, 24 Nov 2003 23:06:41

ecordset .MoveNext command doesn't work for some reason..

Andy wrote: