Hi,
I'm trying to copy an existing form in the same database with a different name. For example, I'm copying the form "Aggregate" to a new name "Aggregate2 "
I'm trying to do create the name of the new form dynamically, but checking to see if the form exists and then incrementing the number. I have done this and it works, but I get a type mismatch error when I try to copy the form.
My code looks like this:
I'm trying to copy an existing form in the same database with a different name. For example, I'm copying the form "Aggregate" to a new name "Aggregate2 "
I'm trying to do create the name of the new form dynamically, but checking to see if the form exists and then incrementing the number. I have done this and it works, but I get a type mismatch error when I try to copy the form.
My code looks like this:
Code:
Dim FormNum As Integer
Dim FormStr As String
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject
FormNum = 2
FormStr = "Aggregate" & FormNum
For Each obj In dbs.AllForms
If obj.Name = "" & FormStr & "" Then
FormNum = FormNum + 1
FormStr = "Aggregate" & FormNum
End If
Next obj
DoCmd.CopyObject FormStr, acForm, "Aggregate"
Comment