Deleting Sub-Form via VBA returns Error 2008

Diskutiere und helfe bei Deleting Sub-Form via VBA returns Error 2008 im Bereich Microsoft Office im Windows Info bei einer Lösung; Hey Community, i'm receiving this error when deleting a Sub-Form via VBA. Here the shortened code with the steps i'm taking. The code resides within... Dieses Thema im Forum "Microsoft Office" wurde erstellt von _R_V_, 1. Februar 2019.

  1. _R_V_
    _R_V_ Gast

    Deleting Sub-Form via VBA returns Error 2008


    Hey Community,

    i'm receiving this error when deleting a Sub-Form via VBA.

    Here the shortened code with the steps i'm taking. The code resides within a module, not within a form, the Sub is invoked by a button in the form "myForm":


    Sub PrepareTemplate()

    Dim oApp As Object

    Dim oObj As AccessObject

    Dim sFormName As String, sSubFormName As String, sSubFormTemplateName As String


    sFormName = "myForm"

    sSubFormName = "mySubForm"

    sSubFormTemplateName = "mySubFormTemplate"


    Set oApp = Application.CurrentProject


    'Close (Parent)Form

    If oApp.AllForms(sFormName).IsLoaded = True Then

    Docmd.Close acForm, sFormName, acSaveNo

    End If


    'Check if the SubForm exists, if it's open close it, then delete it

    For Each oObj In oApp.AllForms

    If oObj.Name = sSubFormName Then

    If oApp.AllForms(sSubFormName).IsLoaded = True Then

    DoCmd.Close acForm, sSubFormName, acSaveNo

    End If

    DoCmd.DeleteObject acForm, sSubFormName '-> throws error 2008 - cannot delete the database object while its open

    End If

    Next oObj


    'Copy template and open subform in design-view for dynamic ctl-creation

    DoCmd.CopyObject , sSubFormTemplateName, acForm, sSubFormName
    DoCmd.OpenForm sSubFormName, acDesign

    ... etc ...

    End Sub



    Edit: I use Office 2016 Pro.

    This code worked before, while the invoking button was on another Form

    Does anybody now what i'm doing wrong here?


    Thanks in advance
     
  2. _R_V_ Win User

    Deleting Sub-Form via VBA returns Error 2008

    It simply won't work, because the button must not sit in the form wich is going to be edited.
  3. Peter_Gyger Win User

    VBA - Office 2013

    Guten Abend

    Ich habe eine Lösung - Internet sei Dank - gefunden :)

    Eine Userform zum Projekt hinzufügen und wieder löschen.

    Damit wir die erforderliche Library "Microsoft Forms 2.0 Objektlibrary" hinzugefügt.

    In der Menge der Bibliotheken habe ich die anfangs nicht gefunden. Fälschlicherweise ging ich davon aus, dass diese über


    Private Sub SetRef()
    
       On Error Resume Next
    
       'Microsoft Forms 2.0 Object Library
    
       Application.VBE.ActiveVBProject.References.AddFromGuid _
    
         "{0D452EE1-E08F-101A-852E-02608C4D0BB4}", 2, 0
    
     End Sub
    dynamisch eingebunden wird.

    Schönen Abend wünsche ich
  4. Markus Kr. Win User

    Shape Objekt (ovaler Kreis) als nicht anklickbar setzen

    Hallo zusammen,



    ich habe in der zwischenzeit lange überlegt. Da es keine passende Eigenschaft des Shape-Objektes gibt, habe ich mir ein Makro geschrieben welches die Zelle darunter selektiert.



    Da ich das shape via VBA erstelle weiße ich in der OnAction-Eigenschaft das Makro zu.

    In dem Makro bestimme ich das aufrufende Objekt und selektiere die Zelle darunter:



    Public Sub markCellBelow()

    'Variablendeklaration

    Dim shpKr As Shape

    On Error GoTo markCellBelow_Error

    'Initialisierung

    'Programmcode

    'Alle Kreise anhand des verwendeten Namens (siehe Function setzeValKreise) wieder entfernen

    For Each shpKr In wsData.Shapes

    If shpKr.name = Application.Caller Then

    shpKr.TopLeftCell.Offset(1, 1).Select

    Exit For

    End If

    Next

    Exit Sub

    'Fehlerroutine

    markCellBelow_Error:

    MsgBox "markCellBelow: Fehler beim markieren der Zelle von Shape: " & Application.Caller & _

    vbCrLf & "Fehlerbeschreibung: " & vbCrLf & Err.Description & "!", vbCritical



    End Sub
  5. Andreas Killer Win User

    Seite einrichten Excel

    Weder noch.

    Entweder Dein Drucker macht das von alleine oder es geht nicht.

    Theoretisch wäre eine Lösung über VBA möglich, jedoch mit automatischem Kassettenwechsel extrem aufwendig.

    Wenn Du 2 Druckertreiber für den gleichen Drucker erzeugen kannst, die jeweils mit den Kassetten drucken,

    dann sollte ein Druck via VBA möglich sein, so grob:

    Sub Test()

    With ActiveSheet

    .PrintOut 1, 1, ActivePrinter:="Drucker Kasette A"

    .PrintOut 2, 999, ActivePrinter:="Drucker Kasette B"

    End With

    End Sub

    Andreas.
  6. Andreas Killer Win User

    Word 2016 per VBA nach Zeit schließen

    Den Code kannst Du vergessen, das geht so schon lange nicht mehr.

    Mach mal eine neue Datei

    VBA Editor auf

    Userform einfügen

    Auf diese einen Label (den etwas größer machen) und einen CommandButton

    Dann diesen Code in die Userform

    Option Explicit
    
    Private Sub CommandButton1_Click()
    
      Unload Me
    
    End Sub
    Dann den Code unten in das Codemodul ThisDocument

    Datei speichern, schließen und wieder öffnen

    Abwarten was passiert. Alles klar?

    Andreas.

    Option Explicit
    
    Dim WithEvents App As Application
    
    Dim Inactivity As Date, CountDown As Date
    
    Private Sub App_WindowSelectionChange(ByVal Sel As Selection)
    
      'Restart the timer if the selection changes
    
      RestartTimer
    
    End Sub
    
    Private Sub Document_Open()
    
      'The AutoClose windows pops uo after this time of inactivity
    
      Inactivity = TimeSerial(0, 0, 5)
    
      'The Autpclose has a countdown timer, 10 seconds + 1 to let the window pop up
    
      CountDown = TimeSerial(0, 0, 11)
    
      'Activate the event
    
      Set App = Application
    
      'Start the timer
    
      RestartTimer
    
    End Sub
    
    Private Sub RestartTimer()
    
      Application.OnTime Now + Inactivity, Me.CodeName & ".AutoCloseMe"
    
    End Sub
    
    Public Sub AutoCloseMe()
    
      Const Msg = "File will be closed in x without saving!"
    
      Dim T As Date
    
      'Errors off, we get an error if the AutoClose window is closed
    
      On Error GoTo ExitPoint
    
      'Load the form
    
      Load UserForm1
    
      With UserForm1
    
        'Prepare the form
    
        .Caption = "Auto Close Timer"
    
        With .CommandButton1
    
          .Caption = "Abort"
    
          'ESC or ENTER triggers the button
    
          .Default = True
    
          .Cancel = True
    
        End With
    
        'Show it modeless means the userform pop up and the code continuos here immediatly
    
        .Show vbModeless
    
        'Wait until the form is visible
    
        Do While Not .Visible
    
          DoEvents
    
        Loop
    
        'Calculate the end time
    
        T = Timer / 86400 + CountDown
    
        'Perform the count down
    
        Do While T > Timer / 86400
    
          'Update the message
    
          .Label1 = Replace(Msg, "x", T - Timer / 86400)
    
          'Let the window update
    
          DoEvents
    
          'Are we on screen?
    
          If Not .Visible Then GoTo ExitPoint
    
        Loop
    
      End With
    
      'If we get here, the user is away
    
      On Error Resume Next
    
      Unload UserForm1
    
      ThisDocument.Close False
    
      Exit Sub
    
    ExitPoint:
    
      'We noticed an action, restart
    
      Unload UserForm1
    
      RestartTimer
    
    End Sub
    
    
  7. User Advert


    Hi,

    willkommen im Windows Forum!
Thema:

Deleting Sub-Form via VBA returns Error 2008 - Microsoft Office

Die Seite wird geladen...

Deleting Sub-Form via VBA returns Error 2008 - Similar Threads - Deleting Sub Form

Forum Datum

Connect to Mailbox via Imap returns error NO AUTENTICATE FAILED, while sending via SMTP...

Connect to Mailbox via Imap returns error NO AUTENTICATE FAILED, while sending via SMTP...: Since yesterday, we recieve multiple errors connecting via IMAP to our outlook.com Mailboxes.We recieve "NO AUTHENTICATE FAILED" while the Activity Page in the Microsoft account shows successful...
Outlook.com 26. Januar 2024

Error in VBA code in Excel

Error in VBA code in Excel: Good morning,I have a VBA code that was working fine and now it keeps bringing up an error message. Can someone help me here please? Thank you!
Microsoft Office 22. Juni 2023

ich möchte via vba auf ein via USB eingebundenes Smartphone zugreifen, wie ich es auf...

ich möchte via vba auf ein via USB eingebundenes Smartphone zugreifen, wie ich es auf...: Das Verzeichnis sieht so aus:SI-PC2 Galaxy Tab S2 TabletAcer C:Wie greife ich mit vba auf das Galaxy... zu?Auf Ordner unter c: habe ich keine Probleme.Produkt MS Access 2019, Windows 11
Microsoft Office 18. Mai 2023

Excel VBA Form Datensatz speichern

Excel VBA Form Datensatz speichern: Hallo Zusammen,ich lasse mir über eine Userform eine Tabelle befüllen.Aktuell wird der Datensatz am Ende angehängt.Ich würde aber gerne das mit dem Button speichern,der DS an der ersten Stelle...
Microsoft Office 10. Dezember 2022

Excel CSV import via VBA - out of memory error

Excel CSV import via VBA - out of memory error: Hello, since beginning of December, I'm experiencing problems with VBA based combined HTML/CSV import to an Excel 2016 workbook. The code imports one text-only HTML file and six CSV files from...
Microsoft Office 28. Dezember 2017

Office 2016 / Excel / VBA - Einzelschrittausführung von Subs über F4

Office 2016 / Excel / VBA - Einzelschrittausführung von Subs über F4: Hallo, früher konnte man bei Excel-VBA die programmierten Subs mit der Taste F4 in Einzelschritten ausführen lassen. Diese Option finde ich bei Office 2016 nicht mehr. Kann mir jemand helfen...
Microsoft Office 26. Juli 2017

Excel VBA Text in Form anzeigen

Excel VBA Text in Form anzeigen: Hallo, NG, ich habe eine Anforderung, die Zellwerte in den nebenstehenden 2 Spalten graphisch darzustellen, mein Vorgänger hat das mit einem Diagramm gemacht, was eher schlecht funktioniert hat,...
Microsoft Office 17. März 2017
Deleting Sub-Form via VBA returns Error 2008 solved
  1. Diese Seite verwendet Cookies, um Inhalte zu personalisieren, diese deiner Erfahrung anzupassen und dich nach der Registrierung angemeldet zu halten.
    Auf dieser Website werden Cookies für die Zugriffsanalyse und Anzeigenmessung verwendet.
    Wenn du dich weiterhin auf dieser Seite aufhältst, akzeptierst du unseren Einsatz von Cookies.