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:
Private Function CheckForData() As Boolean Dim ctl As Control Dim i As Integer For Each ctl In Me.Controls <--- highlighting ctl = value in that control [COLOR=Red][B]i = Forms![Survey Review].ctl.Section [/B] [/COLOR] <--- error here If i = acDetail Then If TypeOf ctl Is CheckBox Then If ctl.Value = True Then CheckForData = True Exit Function End If ElseIf TypeOf ctl Is TextBox Then If Len(ctl.Text) > 0 Then CheckForData = True Exit Function End If End If End If Next End Function




Reply With Quote