Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Public Function getNumberChanges(strDomain As String, strField As String) As Integer
Dim rs As DAO.Recordset
Dim intCounter As Integer
Dim varTemp As Variant
Set rs = CurrentDb.OpenRecordset(strDomain, dbOpenDynaset)
If Not (rs.EOF And rs.BOF) Then
varTemp = rs.Fields(strField)
rs.MoveNext
End If
Do While Not rs.EOF
If Not rs.Fields(strField) = varTemp Then
intCounter = intCounter + 1
varTemp = rs.Fields(strField)
End If
rs.MoveNext
Loop
getNumberChanges = intCounter
End Function
Option Compare Database
Option Explicit
Dim strAllProducts As String
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If InStr(1, strAllProducts, Me.Product) = 0 Then
strAllProducts = strAllProducts & "~" & Me.Product
End If
End Sub
Private Sub ReportFooter_Print(Cancel As Integer, PrintCount As Integer)
'txtProductCount is an unbound text box in the report footer
Me.txtProductCount = Len(strAllProducts) - Len(Replace(strAllProducts, "~", ""))
End Sub
=getNumberChanges([queryProductionRunsBetween2Dates],[Product])
Public Function getNumberChanges(strDomain As String, strField As String) As Integer
[blue]=getNumberChanges(Me.RecordSource,"Product")[/blue]
like to know how many times a product changes from one to another. This is different from how many different products there are.
Dim strWhere as String
strWhere = "[DateField] BETWEEN #1/3/2007# AND #1/5/2007#"
DoCmd.OpenReport "rptProdPerson", acPreview, , strWhere
Dim intCounter As Integer
Dim varTemp As Variant