Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2008
    Posts
    189

    Question Unanswered: How to delete the Forms which starts with some text

    I just want to delete the Forms which starts with "fB - f".

    How can I do that?

    Code:
    For i = 0 To CurrentDb.Containers("Forms").Documents.Count - 1
        vNombreFormularioBorrar = CurrentDb.Containers("Forms").Documents(i).Name
        If Left(vNombreFormularioBorrar, 6) = "fB - f" Then
            DoCmd.Close acForm, vNombreFormularioBorrar, acSaveYes
            MsgBox vNombreFormularioBorrar
            DoCmd.DeleteObject acForm, vNombreFormularioBorrar
        End If
    Next i
    End Sub
    Any ideas?
    Thank you.
    Saludos,
    pepemosca

  2. #2
    Join Date
    Apr 2008
    Posts
    189
    Here is a terrible solution:

    Code:
    Sub sad()
    'OJO NO USAR; ANDA MAL
    For i = CurrentDb.Containers("Forms").Documents.Count - 1 To 0 Step -1
        vNombreFormularioBorrar = CurrentDb.Containers("Forms").Documents(i).Name
        If Left(vNombreFormularioBorrar, 6) = "fB - f" Then
            DoCmd.Close acForm, vNombreFormularioBorrar, acSaveYes
            MsgBox vNombreFormularioBorrar
            On Error Resume Next
            DoCmd.DeleteObject acForm, vNombreFormularioBorrar
        End If
    Next i
    End Sub
    A better way?

  3. #3
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I am a little curious on why you need to programatically delete the forms in the first place. Sometimes just manually deleting forms versus troubleshooting code to delete them is quicker.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  4. #4
    Join Date
    Apr 2008
    Posts
    189
    Hello, my issue is this.

    I have a "PivotChart" Form and also this Form has the desing and controls to be shown as "Continuos Form".

    I want to show this one form also in the PivotChart way and in the "Continuous Form" way.

    So I thought about making a copy of this one form and set the .DefaultView to 1 and 4 on each copy.

    So, when I open the form: one shows the PivotChart and the copy shows the "Continuos Form".

    Any ideas how to do it without having to duplicate the original Form?

    Thanks in advance for your suggestions, comments and help.

  5. #5
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Very different issue. I'd say that subforms would be the answer.

    How is that related to programmatically deleting forms?
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  6. #6
    Join Date
    Apr 2008
    Posts
    189
    Why "subforms"?

    Besides:
    Ok: I could have two Forms all the time on my db.

    I could have the PivotChart version of the form and the acNormal version of the form.

    But I have 96 forms that I would need to duplicate.
    That's why I create them and delete them on the user request.

  7. #7
    Join Date
    Oct 2007
    Posts
    11
    I can understand that you need many forms. I've made large projects taking several years to develop, and they do require 100+ forms.

    Is this, however, the kind of project we're talking about? Are any of those 96 forms similar in any way? If yes, are those similar forms open at the same time?

  8. #8
    Join Date
    Apr 2008
    Posts
    189
    Quote Originally Posted by meingbg
    I can understand that you need many forms. I've made large projects taking several years to develop, and they do require 100+ forms.

    Is this, however, the kind of project we're talking about? Are any of those 96 forms similar in any way? If yes, are those similar forms open at the same time?
    No. Each form is different. Is made by hand because is a different chart.

    I had already 170 charts.

    Yes, is too bad I cannot merge some charts in just one.

    The truth is I use each 170 charts in hundred of combinations.
    So, I it weren't for the VBA I should need hundres times 170.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •