online 1
gast (50)

/ Forum / Datenbanken

DatenbankenDatenbanken

Fragevon stirlitz vom 24.04.2020, 16:50 Options

Access-Formular erstellen VBA

Hallo,

was mache ich falsch? Wenn ich ein Formular mit folgendem Code erstelle, werden alle Variablen geleert. Wird das Formular ohne Quellcode erstellt, behalten die Variablen ihren Wert. Beim ersten Durchlauf wird der Wert der Variable angezeigt, bei zweitem bleibt die MsgBox leer.

Code im Module1
Public TempVariable As String


Code im Formular mit Schaltfläche "Befehl0"
Option Compare Database

Private Sub Form_Load()
    TempVariable = "Test"
End Sub

Private Sub Befehl0_Click()
    
    Dim tmpFormname As String
    Dim frm As Access.Form
    Set frm = Application.CreateForm

    frm.PopUp = 1
    frm.NavigationButtons = False
    frm.RecordSelectors = False
    frm.CloseButton = False
    frm.MinMaxButtons = 0
    frm.ScrollBars = 0
    frm.Caption = "MeinFormular"
    tmpFormname = frm.Name

    'Schaltfläche Abbrechen
    Set cmdAbbrechen = CreateControl(frm.Name, acCommandButton, , "", "", 6500, 750, 1750, 1000)
    cmdAbbrechen.Caption = "Abbrechen"
    cmdAbbrechen.OnClick = "[Ereignisprozedur]"

    LoadModule frm, tmpFormname

    DoCmd.RunCommand acCmdFormView
    
    MsgBox TempVariable

End Sub

Private Sub LoadModule(frm As Access.Form, tmpFormname As String)
    Dim mdl As Access.Module
    Dim Code As String
    
    Code = Code & "Private Sub Befehl0_Click()" & vbCrLf
    Code = Code & "DoCmd.Close acForm, """ & tmpFormname & """, acSaveNo" & vbCrLf
    Code = Code & "End Sub"
    
    Set mdl = frm.Module
    mdl.InsertText Code
End Sub


Danke für Eure Hilfe im Voraus


Antwort schreiben

Antwort 1 von Marie vom 27.04.2020, 00:02 Options

ja, echt komisch :-((

Gruß Marie

Ähnliche Themen

Access-Formular kopieren?
Sanne  29.06.2007 - 174 Hits - 5 Antworten

access formular exportieren
ichhabeinefrage  13.08.2007 - 277 Hits - 2 Antworten

Mehrseitiges Formular in Access
blaq.  02.10.2007 - 199 Hits - 1 Antwort

aus Access Verknüpfung erstellen
rolandaa  21.11.2007 - 170 Hits - 2 Antworten

VBA-Excel
mentosbasi  28.05.2008 - 350 Hits - 3 Antworten

Hinweis

Diese Frage ist schon etwas älter, Sie können daher nicht mehr auf sie antworten. Sollte Ihre Frage noch nicht gelöst sein, stellen Sie einfach eine neue Frage im Forum..

Neue Einträge

Version: supportware 1.9.150 / 10.06.2022, Startzeit:Thu Jan 8 21:07:44 2026