Neuigkeiten:

Ist euer Problem gelöst, dann bitte den Knopf "Thema gelöst" drücken!

Mobiles Hauptmenü

Access öffnet sich und schließt sich dann wieder

Begonnen von MarkusR, März 29, 2012, 14:14:05

⏪ vorheriges - nächstes ⏩

MarkusR

Hallo zusammen,

ich glaube, ich habe gerade meine Datenbank zerschossen  :'(

Ich wollte die so einstellen, dass sich mein Hauptformular automatisch als Popup öffnet, aber das Hauptfenster von Access im Hintergrund nicht zu sehen ist. Dazu habe ich einen Code von DonKarl benutzt:

Im Deklarationsbereich des Formularmodules in deinem Übersichtsformular:

Const SW_HIDE = 0
'in A00 ist dazu noch nötig:
'Const SW_NORMAL = 1

Private Declare Function ShowWindow Lib "user32" _
    (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

In der Öffnen-Sub deines Übersichtsformulares:

Dim hWindow As Long
Dim nResult As Long
Dim nCmdShow As Long
hWindow = Application.hWndAccessApp
nCmdShow = SW_HIDE
nResult = ShowWindow(ByVal hWindow, ByVal nCmdShow)
'in A00 ist dazu noch nötig:
'call ShowWindow(Me.hWnd, SW_NORMAL)


Wenn ich Access jetzt öffne, lädt er kurz, dann schließt sich das Fenster wieder und Access läuft nur noch als Prozess. Aber es wird kein Fenster, kein Popup oder sonstiges angezeigt. Daher habe ich keine Ahnung, wie ich das jetzt wieder Rückgängig machen kann....AAAAHHH!!

Bitte bitte helft mir! Dankeeeee

MarkusR

Hat sich schon erledigt...Shift + öffen...Puuuuh

MarkusR

So, komme jetzt aber nicht wirklich weiter...

Meine Formulare sind alle als Popup eingestellt, nur wenn ich Access minimiere, werden auch die Formulare minimiert.
Ich habe jetzt ein Modul, das wie folgt aussieht:

Option Compare Database

Option Explicit
' getestet mit AC97

Private Declare Function FindWindow Lib "user32" Alias _
    "FindWindowA" (ByVal lpClassName As String, _
                   ByVal lpWindowName As String) As Long
Private Declare Function GetWindowPlacement Lib "user32" _
    (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
Private Declare Function SetWindowPlacement Lib "user32" _
    (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
Private Declare Function SetForegroundWindow Lib "user32" _
    (ByVal hwnd As Long) As Long
Private Declare Function BringWindowToTop Lib "user32" _
    (ByVal hwnd As Long) As Long

Const SW_SHOWNORMAL = 1
Const SW_SHOWMINIMIZED = 2

Private Type POINTAPI
    x As Long
    y As Long
End Type

Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Private Type WINDOWPLACEMENT
    Length As Long
    flags As Long
    showCmd As Long
    ptMinPosition As POINTAPI
    ptMaxPosition As POINTAPI
    rcNormalPosition As RECT
End Type

Private Function ActivateWindow(xhWnd&) As Boolean
    Dim Result&, WndPlcmt As WINDOWPLACEMENT

    With WndPlcmt
        .Length = Len(WndPlcmt)
        Result = GetWindowPlacement(xhWnd, WndPlcmt)
        If Result Then
            If .showCmd = SW_SHOWMINIMIZED Then
                .flags = 0
                .showCmd = SW_SHOWNORMAL
                Result = SetWindowPlacement(xhWnd, WndPlcmt)
              Else
                Call SetForegroundWindow(xhWnd)
                Result = BringWindowToTop(xhWnd)
            End If
            If Result Then ActivateWindow = True
        End If
    End With
  End Function

Private Function DeActivateWindow(xhWnd&) As Boolean
    Dim Result&, WndPlcmt As WINDOWPLACEMENT

    With WndPlcmt
        .Length = Len(WndPlcmt)
        Result = GetWindowPlacement(xhWnd, WndPlcmt)
        If Result Then
                .flags = 0
                .showCmd = SW_SHOWMINIMIZED
                Result = SetWindowPlacement(xhWnd, WndPlcmt)
                If Result Then DeActivateWindow = True
        End If
    End With
End Function


Und in einem der Formulare habe ich einen Button mit Befehl hinterlegt:

Private Sub Minimieren_Click()
    Dim xhWnd&

    xhWnd = FindWindow("OMain", vbNullString)
    DeActivateWindow xhWnd
End Sub


Wenn ich jetzt aber den Button klicke, bekomme ich die Fehlermeldung "Fehler beim Kompilieren: Sub oder Function nicht definiert" und FindWindow wird markiert.
Sieht jemand den Fehler?

Danke mal wieder im Voraus! Gruß,
Markus

DF6GL

Hallo,

Public Declare Function FindWindow .....

Was willst Du denn überhaupt machen?
Viele Grüße vom Bodensee
Franz, DF6GL

Hilfestellung:  http://www.access-o-mania.de/forum/index.php?topic=6969.msg118738#msg118738

Links und Tipps:
1.   http://v.hdm-stuttgart.de/~riekert/lehre/db-kelz/
1a. http://www.tinohempel.de/info/info/datenbank/normalisierung.htm
1b. https://support.office.com/de-de/article/Grundlagen-des-Datenbankentwurfs-eb2159cf-1e30-401a-8084-bd4f9c9ca1f5#bmterms
2.   http://www.donkarl.com
3.   https://web.archive.org/web/20201201233522/http://www.dbwiki.net/
4.   http://www.access-tutorial.de/
5.   http://www.tty1.net/smart-questions_de.htm
6.   http://access.joposol.com/accept

Last but not least:   < F1 > für Hilfe
;) Learning by doing not by spoon-feed ;)

Tipp: Find and Replace for Access