Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writeing to the RegBase and control your windows

Functions

Writeing to the RegBase and control your windows

by  hermanlaksko  Posted    (Edited  )
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 ;-)
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top