This is an Access 97 db. I want to loop through the controls in the detail section of a form only, and have the code below. Access throws an Application or Object defined error at the indicated spot. If I highlight "ctl", Access gives the value that's in the textbox which is the first control, e.g. the date. I'm basically trying to make sure the user has entered at least some data in the detail area of the form before it's saved. Thanks.
VB Code:
  1. Private Function CheckForData() As Boolean
  2.     Dim ctl As Control
  3.     Dim i As Integer
  4.    
  5.     For Each ctl In Me.Controls   <--- highlighting ctl = value in that control
  6.         [COLOR=Red][B]i = Forms![Survey Review].ctl.Section   [/B] [/COLOR] <--- error here
  7.         If i = acDetail Then
  8.         If TypeOf ctl Is CheckBox Then
  9.             If ctl.Value = True Then
  10.                 CheckForData = True
  11.                 Exit Function
  12.             End If
  13.         ElseIf TypeOf ctl Is TextBox Then
  14.             If Len(ctl.Text) > 0 Then
  15.                 CheckForData = True
  16.                 Exit Function
  17.             End If
  18.         End If
  19.         End If
  20.     Next
  21. End Function