Delete Objects based on a partial name

RobJen

Registered User.
Local time
Today, 17:47
Joined
Jul 19, 2005
Messages
35
Hi, I've been looking for a way to delete forms based on a wildcard. My module generates new forms but after it's closed I need to delete them. This is actually bypassing the annoying "save as" prompt you get when creating a new form.

Anyone has an idea on how to achieve this? The forms are named just as any new form would be:

Form1
Form2
Form3

I know how to do this in PHP but no luck in VBA yet.

Thanks!
 
Hello

Put the below code under a command button and run.
'
Private Sub cmdTest_Click()
Dim MyCheck As Boolean
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject
' Search for open AccessObject objects in AllForms collection.
For Each obj In dbs.AllForms
' Print name of obj.
'
MyCheck = obj.Name Like "Form#" '
If MyCheck = True Then
Debug.Print obj.Name
End If

Next obj

End Sub
'
It should display the name of all forms named in the format of FORM1, FORM2 etc.
Tested using form1
'
Regards
 

Users who are viewing this thread

Back
Top Bottom