R
Rasho
The following code is repeated for 31 days.
'fldCurr.Name = Date continues on for current date + (ie Date+1, Date+2)
'Me.Crew_1.ControlSource = strFieldName continues on (Me.Crew_1, Me.Crew_2)
The code below works fine for each day though I would like to know if it
is possible to loop through a Pivot tables fields using a For Each type loop
or
For i = 1 to Pivot table fields.count type loop? As the below code when
repeated 31 times slows the program down.
Sub C1()
On Error GoTo errControl
Dim dbCurr As DAO.Database
Dim qdfCurr As DAO.QueryDef
Dim fldCurr As DAO.Field
Dim strFieldName As String
Set dbCurr = CurrentDb()
Set qdfCurr = dbCurr.QueryDefs("qry_BACWhite_register")
For Each fldCurr In qdfCurr.Fields
If fldCurr.Name = Date Then
strFieldName = fldCurr.Name
Exit For
End If
Next
If fldCurr.Name <> "" Then
Me.Crew_1.ControlSource = strFieldName
End If
errControl:
If Err.Number = 91 Then
Me.Crew_1.ControlSource = ""
End If
Resume Next
End Sub
'fldCurr.Name = Date continues on for current date + (ie Date+1, Date+2)
'Me.Crew_1.ControlSource = strFieldName continues on (Me.Crew_1, Me.Crew_2)
The code below works fine for each day though I would like to know if it
is possible to loop through a Pivot tables fields using a For Each type loop
or
For i = 1 to Pivot table fields.count type loop? As the below code when
repeated 31 times slows the program down.
Sub C1()
On Error GoTo errControl
Dim dbCurr As DAO.Database
Dim qdfCurr As DAO.QueryDef
Dim fldCurr As DAO.Field
Dim strFieldName As String
Set dbCurr = CurrentDb()
Set qdfCurr = dbCurr.QueryDefs("qry_BACWhite_register")
For Each fldCurr In qdfCurr.Fields
If fldCurr.Name = Date Then
strFieldName = fldCurr.Name
Exit For
End If
Next
If fldCurr.Name <> "" Then
Me.Crew_1.ControlSource = strFieldName
End If
errControl:
If Err.Number = 91 Then
Me.Crew_1.ControlSource = ""
End If
Resume Next
End Sub