Walking Fields on A Form in VBA - BCP

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with a series of fields they are named sequentially ie.
Forms![EMail Automation1]![FrmProblemTicketEntry].Form![AddlEmnt1]
Forms![EMail Automation1]![FrmProblemTicketEntry].Form![AddlEmnt2]
....
Forms![EMail Automation1]![FrmProblemTicketEntry].Form![AddlEmnt12]

I want to create a loop to go through the fields something like this
For i = 1 To 12
FieldName = "[AddlEmnt" & i
If Forms![EMail Automation1]![FrmProblemTicketEntry]!& FieldName > "" Then
AddtionalElementChanges = AddtionalElementChanges + 1
End If
Next i

Is there a way to manipulate the name of the field on the form so I don't
have to write 12 identical if statements to loop through the 12 fields.
 
Try using

For i = 1 To 12
If Forms![EMail Automation1]![FrmProblemTicketEntry].Form("AddlEmnt" &
Format(i,"0")) > "" Then
AddtionalElementChanges = AddtionalElementChanges + 1
End If
Next i

Hope this helps.
 
Back
Top