dynamically remove recordsource (1 Viewer)

abenitez77

Registered User.
Local time
Today, 08:47
Joined
Apr 29, 2010
Messages
141
How can i remove all recordsources from all forms and subforms in my app? I want to do this with vba to loop thru all forms and remove all recordsources.

thanks!
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 08:47
Joined
May 21, 2018
Messages
8,463
Although he stated Forms collection, he meant the AllForms collection as per the link. The Forms collection only holds open forms.
Code:
Public Sub ModForms()
  Dim frm As Access.Form
  Dim frmObj As AccessObject
  For Each frmObj In CurrentProject.AllForms
    DoCmd.OpenForm frmObj.Name, acDesign
    Set frm = Forms(frmObj.Name)
    'do code here
    'frm.Caption = "Changed"
    DoCmd.Close acForm, frm.Name, acSavePrompt
  Next frmObj
End Sub
 

Users who are viewing this thread

Top Bottom