Web Development
3 replies
by peyison
One way to do this would be to create a sub-report and have the subreport contain the textbox you wanted. Another way is to do it in VBA code.
Right click in the Detail area of the report. Select Build Event -> Code Builder. It will take you to the Detail_Format event. This event is fired when the detail area is being formatted. At this point, you can do a query and assign the results to an unbound text box in the detail section (in this example, named tbxEmpCount)
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim db As Database
Dim rst As Recordset
Dim sSql As String
sSql = "Select Count(EmpIds) as CountEmps from tblEmployees"
Set db = CurrentDb
Set rst = db.OpenRecordset(sSql)
If Notrst.EOF or Not IsNull(rst.EOF) Then
tbxEmpCount = oRst!CountEmps
Else
tbxEmpCount = 0
Loop
rst.Close
Set rst = Nothing
Set db = Nothing
End Sub
-------------
Hope this helps.
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending