UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Pass Values Of Form Location To Table, Access 2013    
 
   
fitzdesignz
post Oct 11 2018, 01:39 PM
Post#1



Posts: 34
Joined: 14-June 18



I'm attempting to save a forms window location to a table when form is closed so that I can open the next form in the same position. (The main access window is hidden)

Here is my code:

CODE
Private Sub Form_Close()
'   Record Application window location to table
    
    Dim AppWinTop As String
    Dim AppWinLeft As String
    
    AppWinTop = Me.WindowTop
    AppWinLeft = Me.WindowLeft

    CurrentDb.Execute "UPDATE tbl_AppSystemFront Set tbl_AppSystemFront.AppWindowLeft = AppWinLeft, tbl_AppSystemFront.AppWindowTop = AppWinTop Where ID = 2"


I'm getting an too few parameters run time error when it runs. Any ideas?

Go to the top of the page
 
theDBguy
post Oct 11 2018, 01:46 PM
Post#2


Access Wiki and Forums Moderator
Posts: 73,965
Joined: 19-June 07
From: SunnySandyEggo


Hi,

Was it expecting two (2) arguments/parameters? If so, try the following SQL statement:

CODE
CurrentDb.Execute "UPDATE tbl_AppSystemFront Set tbl_AppSystemFront.AppWindowLeft = " _
    & AppWinLeft & ", tbl_AppSystemFront.AppWindowTop = " & AppWinTop & " Where ID = 2", dbFailOnError

The above assumes the fields in your tables are numeric fields. If they're actually text fields, then try it this way:

CODE
CurrentDb.Execute "UPDATE tbl_AppSystemFront Set tbl_AppSystemFront.AppWindowLeft = '" _
    & AppWinLeft & "', tbl_AppSystemFront.AppWindowTop = '" & AppWinTop & "' Where ID = 2", dbFailOnError

Hope it helps...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
fitzdesignz
post Oct 11 2018, 02:09 PM
Post#3



Posts: 34
Joined: 14-June 18



Thanks theDBguy your first suggestion worked!

Another quick question... If I'm using this so the next form that is open reads the location and set itself to it. Should this be put in the On Close or On Deactivate event? and the next form that is opened, should I call the locations on the On Load, On activate, or OnOpen event?

Thanks again for your help.
Go to the top of the page
 
theDBguy
post Oct 11 2018, 02:13 PM
Post#4


Access Wiki and Forums Moderator
Posts: 73,965
Joined: 19-June 07
From: SunnySandyEggo


Hi,

I think any of those event would work just fine because all of them fire at the same time anyway (or in sequence with each other) when you open or close a form.

You can do some tests and see which one fits you best.

Good luck!

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    18th December 2018 - 09:01 PM