recordset and place it into the proper fields in a Report?
I have a report that needs to have three sections of items from three different record sources. I have the results from one query how do I add the results to fields in my report. I realize these fields will need to be unbound so I can fill them with the proper results based on my recordset.
Here is my code, which gives me the reults I require. What I need to do is now take that results place it in a specific section in the report.
Private Sub Report_Page()
'*Purpose: Build recordets to open our many sections to display the customers data.
On Error GoTo DefaultHandler
Dim rstCigar As ADODB.Recordset
Dim strSQLCigar As String
Dim lngCustomerID As Long
Dim strResultCigarItem As String
'capture the proper customer ID to use in our where clause.
lngCustomerID = txtCigarCustomerID
'*build our SQl query to retriev the results for the specific customer
strSQLCigar = "SELECT cigarInvNumID, CustomerID_FK, CustomerNumber, Cigar_InvoiceNumber, Cigar_OrderDate, Cigar_ItemPurchased, Cigar_ProductRetail " & _
"FROM OrderDetailsCigar " & _
"WHERE CustomerID_FK = " & lngCustomerID & ";"
'* open our recordset here
Set rstCigar = New ADODB.Recordset
rstCigar.ActiveConnection = CurrentProject.Connection
rstCigar.CursorType = adOpenKeyset
rstCigar.Source = strSQLCigar
rstCigar.Open
'*Retrieve the recordset results here
Do While Not rstCigar.EOF
strResultCigarItem = rstCigar.Fields("Cigar_ItemPurchased").Value
Debug.Print strResultCigarItem
rstCigar.MoveNext
Loop
SubExit:
'set our recordset to nothing cleaning up after ourselves.
Set rstCigar = Nothing
Exit Sub
DefaultHandler:
Select Case Err.Number
'* Handle errors here.
Case Else
MsgBox "Error:" & " " & Me.Name & ": " & Err.Number & vbCrLf _
& Err.Description
End Select
Resume SubExit
End Sub
Life's a journey enjoy the ride...
jazzz
I have a report that needs to have three sections of items from three different record sources. I have the results from one query how do I add the results to fields in my report. I realize these fields will need to be unbound so I can fill them with the proper results based on my recordset.
Here is my code, which gives me the reults I require. What I need to do is now take that results place it in a specific section in the report.
Private Sub Report_Page()
'*Purpose: Build recordets to open our many sections to display the customers data.
On Error GoTo DefaultHandler
Dim rstCigar As ADODB.Recordset
Dim strSQLCigar As String
Dim lngCustomerID As Long
Dim strResultCigarItem As String
'capture the proper customer ID to use in our where clause.
lngCustomerID = txtCigarCustomerID
'*build our SQl query to retriev the results for the specific customer
strSQLCigar = "SELECT cigarInvNumID, CustomerID_FK, CustomerNumber, Cigar_InvoiceNumber, Cigar_OrderDate, Cigar_ItemPurchased, Cigar_ProductRetail " & _
"FROM OrderDetailsCigar " & _
"WHERE CustomerID_FK = " & lngCustomerID & ";"
'* open our recordset here
Set rstCigar = New ADODB.Recordset
rstCigar.ActiveConnection = CurrentProject.Connection
rstCigar.CursorType = adOpenKeyset
rstCigar.Source = strSQLCigar
rstCigar.Open
'*Retrieve the recordset results here
Do While Not rstCigar.EOF
strResultCigarItem = rstCigar.Fields("Cigar_ItemPurchased").Value
Debug.Print strResultCigarItem
rstCigar.MoveNext
Loop
SubExit:
'set our recordset to nothing cleaning up after ourselves.
Set rstCigar = Nothing
Exit Sub
DefaultHandler:
Select Case Err.Number
'* Handle errors here.
Case Else
MsgBox "Error:" & " " & Me.Name & ": " & Err.Number & vbCrLf _
& Err.Description
End Select
Resume SubExit
End Sub
Life's a journey enjoy the ride...
jazzz