I am trying to clear all of the rowsources for the controls in a form upon exiting the form, and I found this short piece of code to do just that. The code seems to run OK when I close the form, but when I open it again the rowsource values have not been cleared. I would appreciate any assistance.
Private Sub Form_Unload(Cancel As Integer)
Dim ctl As Control
Me.RecordSource = ""
For Each ctl In Me.Controls
Select Case ctl.Properties("ControlType")
Case acComboBox, acListBox
ctl.RowSource = ""
Case acSubform
ctl.Form.RecordSource = ""
Case Else
'do nothing
End Select
Next ctl
Set ctl = Nothing
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim ctl As Control
Me.RecordSource = ""
For Each ctl In Me.Controls
Select Case ctl.Properties("ControlType")
Case acComboBox, acListBox
ctl.RowSource = ""
Case acSubform
ctl.Form.RecordSource = ""
Case Else
'do nothing
End Select
Next ctl
Set ctl = Nothing
End Sub