The window position thing only works in A-XP, but the below shows you how to write to and read from the registration database.
1. On form open event insert:
FormRegGet Me.Name
2. On Form close event insert:
FormRegSet Me.Name
3.
Function FormRegSet(MyForm)
On Error Resume Next
Dim Frm As Form
Dim FTop, FLeft, FTopOld
Set Frm = Forms(MyForm)
FTop = 0: FLeft = 0: FTopOld = 0
FTop = Frm.WindowTop
FLeft = Frm.WindowLeft
FTopOld = GetSetting("YourApp", "FormsPosition", MyForm & "T")
If FTop - FTopOld = 345 Then FTop = FTop - 345 'Menulinie chk
SaveSetting "YourApp", "FormsPosition", MyForm & "T", FTop
SaveSetting "YourApp", "FormsPosition", MyForm & "L", FLeft
End Function
4.
Function FormRegGet(MyForm As String)
Dim FLeft, FTop
Dim Frm As Form
Set Frm = Forms(MyForm)
FTop = GetSetting("YourApp", "FormsPosition", MyForm & "T") ' - 345 '= menulinie
FLeft = GetSetting("YourApp", "FormsPosition", MyForm & "L")
If Not IsBlank(FTop) And Not IsBlank(FLeft) Then DoCmd.MoveSize FLeft, FTop
End Function
I have used "T" for TopPosition of the window and "L" for left position.
You will find your inserted information in the regbase under HKey_Current_User/Software/VB and VBA Program Settings/YourApp.
Have fun ;-)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.