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
Hat sich schon erledigt...Shift + öffen...Puuuuh
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
Hallo,
Public Declare Function FindWindow .....
Was willst Du denn überhaupt machen?