Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop thru Form Controls

Status
Not open for further replies.

jw5107

Technical User
Jan 20, 2004
294
US
Below is what I am working with...

I need to warn the user to save the record (if the controls have data in them) before they close out of the form, otherwise if the form is blank (or all the contols contain null data), then just close the form...
I just can't get this to work...!!! Any suggestions or examples..??

For Each ctrl In Me.Controls
If ctrl.ControlType = acTextBox Or ctrl.ControlType = acComboBox Then
If IsNull(ctrl) Then
Forms![MainMenu].Visible = True
Exit Sub
End If
Else
DisplayMessage "This delay has not been saved...!!!" & vbCrLf & "Either click on 'Add Delay' to add this delay event" & vbCrLf & "OR - click on 'Clear' to clear the form out before going to the Main Menu"
End If
Next ctrl
 
You seem to have your End If in the wrong place:

Code:
For Each ctrl In Me.Controls
If ctrl.ControlType = acTextBox Or ctrl.ControlType = acComboBox Then
If IsNull(ctrl) Then
  Forms![MainMenu].Visible = True
  Exit Sub
Else
  DisplayMessage "This delay has not been saved...!!!" & vbCrLf & "Either click on 'Add Delay' to add this delay event" & vbCrLf & "OR - click on 'Clear' to clear the form out before going to the Main Menu"
End If
End If


Next ctrl[/code]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top