Cannot update controls on the first page of the report

acidtechno

New member
Local time
Today, 10:56
Joined
May 24, 2007
Messages
9
Hi.

I've created a report based on a query. I have some text boxes in the report bound to the fields that are connected to the report.

I have also some unbound text boxes on the report and I want to update them manually using VBA. The problem is that everything works fine but not on the first page of the report. Text boxes are updated nicely on pages > 1.

I use OnPage event of the report to update textboxes and I do something like this:

Code:
Private Sub Report_Page()
    
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim sSQL As String
    
    sSQL = "SELECT Points.Points, Points.CriterionID As CriterionID, Marks.Name AS MarkName " & _
           "FROM Results, Points, Marks " & _
           "WHERE Results.SessionID = " & txtID.Value & " AND Results.PointID = Points.ID AND Points.MarkID = Marks.ID"
    
    Set cn = CurrentProject.Connection
    
    Set rs = New ADODB.Recordset
    
    rs.Open sSQL, cn
    
    While Not rs.EOF
            
        If rs.Fields("CriterionID") = 1 Then
        
            Opening1.Value = rs.Fields("MarkName")
            
        ElseIf rs.Fields("CriterionID") = 2 Then
        
            Opening2.Value = rs.Fields("MarkName")
            
            (...)
                        
        End If
        
        rs.MoveNext
        
    Wend
    
    rs.Close
    cn.Close

End Sub

When I lanuch the report I dont see data on the first page, but when I switch to another pages it works fine. I dont know where the problem is. Please help.
 
Use the format event of the particular section you want updated.
 
Awesome! Thank you very much!!

That was the fastest reply ever! Works fine now :)
 

Users who are viewing this thread

Back
Top Bottom