how to save a resized form?

K

Kiers

Hi All,

i have a main form and subform (datasheet), that is set up to allow
the user to resize to meet their own requirements - which works fine.
The problem i have is that i cannot work out how to save the new
resized form, so that the next time it is opened it is displayed as
the user last left it.

Access 2007

Any suggestions would be greatly appreciated.

Rgds

Kiers
 
D

Damon Heron

Maybe someone with more expertise can weigh in on this, but the only way I
can think of to do this is to set up a table, two fields, no primary key -
I call it tblFrmHW, with formHt, and formWd fields.

on the load event of the form,lookup the values of Height and Width.

Private Sub Form_Load()
Dim x As Long
Dim y As Long
x = Nz(DLookup("formHt", "tblFrmHW"), 8040)
'first time fields will be null,
'therefore the values
y = Nz(DLookup("formWd", "tblFrmHW"), 13170)
DoCmd.MoveSize , , y, x
' size the form to the values
End Sub

Private Sub Form_Close()' on form close, get the insidewidth
' and height of the form.
' the InsideH & W are less the size of form, so I add a few twips
Dim x As Long
Dim y As Long
Dim strsql As String
x = Me.InsideHeight + 955
y = Me.InsideWidth + 435

strsql = "Update tblFrmHW set tblFrmHW.formHt= " & [x] & ", " &
"tblFrmHW.formWd= " & [y] & ""
'(the sql statement should be on one line)
DoCmd.RunSQL strsql
'Saved old values to table.
End Sub

HTH
Damon
 
M

Mr B

I would suggest that you might actually want to expand a little on that Damon
has suggested.

In your table you might want to include a field for the ID of the current
user so that if you have multiple users you can allow each user to set the
size of the form as they want it and you would then simpley add their Id to
the criteria when retrieving the values for the size of the form.

You may also want to include a field for the Height of each individual
section of the form: Header, Detail and Footer.

Just my thoughts. Depends on just how far you want to go.

Good luck with your project.

--
HTH

Mr B
askdoctoraccess dot com


Damon Heron said:
Maybe someone with more expertise can weigh in on this, but the only way I
can think of to do this is to set up a table, two fields, no primary key -
I call it tblFrmHW, with formHt, and formWd fields.

on the load event of the form,lookup the values of Height and Width.

Private Sub Form_Load()
Dim x As Long
Dim y As Long
x = Nz(DLookup("formHt", "tblFrmHW"), 8040)
'first time fields will be null,
'therefore the values
y = Nz(DLookup("formWd", "tblFrmHW"), 13170)
DoCmd.MoveSize , , y, x
' size the form to the values
End Sub

Private Sub Form_Close()' on form close, get the insidewidth
' and height of the form.
' the InsideH & W are less the size of form, so I add a few twips
Dim x As Long
Dim y As Long
Dim strsql As String
x = Me.InsideHeight + 955
y = Me.InsideWidth + 435

strsql = "Update tblFrmHW set tblFrmHW.formHt= " & [x] & ", " &
"tblFrmHW.formWd= " & [y] & ""
'(the sql statement should be on one line)
DoCmd.RunSQL strsql
'Saved old values to table.
End Sub

HTH
Damon



Kiers said:
Hi All,

i have a main form and subform (datasheet), that is set up to allow
the user to resize to meet their own requirements - which works fine.
The problem i have is that i cannot work out how to save the new
resized form, so that the next time it is opened it is displayed as
the user last left it.

Access 2007

Any suggestions would be greatly appreciated.

Rgds

Kiers
 
D

Damon Heron

All good suggestions.
Damon

Mr B said:
I would suggest that you might actually want to expand a little on that
Damon
has suggested.

In your table you might want to include a field for the ID of the current
user so that if you have multiple users you can allow each user to set the
size of the form as they want it and you would then simpley add their Id
to
the criteria when retrieving the values for the size of the form.

You may also want to include a field for the Height of each individual
section of the form: Header, Detail and Footer.

Just my thoughts. Depends on just how far you want to go.

Good luck with your project.

--
HTH

Mr B
askdoctoraccess dot com


Damon Heron said:
Maybe someone with more expertise can weigh in on this, but the only way
I
can think of to do this is to set up a table, two fields, no primary
key -
I call it tblFrmHW, with formHt, and formWd fields.

on the load event of the form,lookup the values of Height and Width.

Private Sub Form_Load()
Dim x As Long
Dim y As Long
x = Nz(DLookup("formHt", "tblFrmHW"), 8040)
'first time fields will be null,
'therefore the values
y = Nz(DLookup("formWd", "tblFrmHW"), 13170)
DoCmd.MoveSize , , y, x
' size the form to the values
End Sub

Private Sub Form_Close()' on form close, get the insidewidth
' and height of the form.
' the InsideH & W are less the size of form, so I add a few twips
Dim x As Long
Dim y As Long
Dim strsql As String
x = Me.InsideHeight + 955
y = Me.InsideWidth + 435

strsql = "Update tblFrmHW set tblFrmHW.formHt= " & [x] & ", " &
"tblFrmHW.formWd= " & [y] & ""
'(the sql statement should be on one line)
DoCmd.RunSQL strsql
'Saved old values to table.
End Sub

HTH
Damon



Kiers said:
Hi All,

i have a main form and subform (datasheet), that is set up to allow
the user to resize to meet their own requirements - which works fine.
The problem i have is that i cannot work out how to save the new
resized form, so that the next time it is opened it is displayed as
the user last left it.

Access 2007

Any suggestions would be greatly appreciated.

Rgds

Kiers
 
K

Kiers

All good suggestions.
Damon

"Mr B" <draccess at askdoctoraccess dot com> wrote in message

I would suggest that you might actually want to expand a little on that
Damon
has suggested.
In your table you might want to include a field for the ID of the current
user so that if you have multiple users you can allow each user to set the
size of the form as they want it and you would then simpley add their Id
to
the criteria when retrieving the values for the size of the form.
You may also want to include a field for the Height of each individual
section of the form:  Header, Detail and Footer.
Just my thoughts.  Depends on just how far you want to go.
Good luck with your project.
Mr B
askdoctoraccess dot com
Maybe someone with more expertise can weigh in on this, but the only way
I
can think of to do this is to set up a table, two fields, no primary
key -
I call it tblFrmHW, with formHt, and formWd fields.
on the load event of the form,lookup the values of Height and Width.
Private Sub Form_Load()
 Dim x As Long
 Dim y As Long
 x = Nz(DLookup("formHt", "tblFrmHW"), 8040)
 'first time fields will be null,
 'therefore the values
 y = Nz(DLookup("formWd", "tblFrmHW"), 13170)
 DoCmd.MoveSize , , y, x
 ' size the form to the values
End Sub
Private Sub Form_Close()' on form close, get the insidewidth
' and height of the form.
' the InsideH & W are less the size of form, so I add a few twips
 Dim x As Long
 Dim y As Long
 Dim strsql As String
 x = Me.InsideHeight + 955
 y = Me.InsideWidth + 435
strsql = "Update tblFrmHW set tblFrmHW.formHt= " & [x] &  ", " &
"tblFrmHW.formWd= " & [y] & ""
'(the sql statement should be on one line)
 DoCmd.RunSQL strsql
'Saved old values to table.
End Sub
HTH
Damon
Hi All,
i have a main form and subform (datasheet), that is set up to allow
the user to resize to meet their own requirements - which works fine..
The problem i have is  that i cannot work out how to save the new
resized form, so that the next time it is opened it is displayed as
the user last left it.
Access 2007
Any suggestions would be greatly appreciated.
Rgds
Kiers- Hide quoted text -

- Show quoted text -

Hi Guys,

thanks for the suggestions. I now have something to work with. I think
i will also add an extra field to the table for the forma name. This
way i can allow the user to resize mutliple forms.

Thanks again for your time.

Kiers
 
K

Kiers

All good suggestions.
Damon
"Mr B" <draccess at askdoctoraccess dot com> wrote in messagenews:D[email protected]...
I would suggest that you might actually want to expand a little on that
Damon
has suggested.
In your table you might want to include a field for the ID of the current
user so that if you have multiple users you can allow each user to set the
size of the form as they want it and you would then simpley add theirId
to
the criteria when retrieving the values for the size of the form.
You may also want to include a field for the Height of each individual
section of the form:  Header, Detail and Footer.
Just my thoughts.  Depends on just how far you want to go.
Good luck with your project.
--
HTH
Mr B
askdoctoraccess dot com
:
Maybe someone with more expertise can weigh in on this, but the onlyway
I
can think of to do this is to set up a table, two fields, no primary
key -
I call it tblFrmHW, with formHt, and formWd fields.
on the load event of the form,lookup the values of Height and Width.
Private Sub Form_Load()
 Dim x As Long
 Dim y As Long
 x = Nz(DLookup("formHt", "tblFrmHW"), 8040)
 'first time fields will be null,
 'therefore the values
 y = Nz(DLookup("formWd", "tblFrmHW"), 13170)
 DoCmd.MoveSize , , y, x
 ' size the form to the values
End Sub
Private Sub Form_Close()' on form close, get the insidewidth
' and height of the form.
' the InsideH & W are less the size of form, so I add a few twips
 Dim x As Long
 Dim y As Long
 Dim strsql As String
 x = Me.InsideHeight + 955
 y = Me.InsideWidth + 435
strsql = "Update tblFrmHW set tblFrmHW.formHt= " & [x] &  ", "&
"tblFrmHW.formWd= " & [y] & ""
'(the sql statement should be on one line)
 DoCmd.RunSQL strsql
'Saved old values to table.
End Sub
HTH
Damon
Hi All,
i have a main form and subform (datasheet), that is set up to allow
the user to resize to meet their own requirements - which works fine.
The problem i have is  that i cannot work out how to save the new
resized form, so that the next time it is opened it is displayed as
the user last left it.
Access 2007
Any suggestions would be greatly appreciated.
Rgds
Kiers- Hide quoted text -
- Show quoted text -

Hi Guys,

thanks for the suggestions. I now have something to work with. I think
i will also add an extra field to the table for the forma name. This
way i can allow the user to resize mutliple forms.

Thanks again for your time.

Kiers- Hide quoted text -

- Show quoted text -

Hi Guys,

to close of the thread, i thought i would post my solution, which is
different to those posted above.

After much searching i came up with the following code for the 'open'
and 'close' events for the form in qustion

Private Sub Form_Open(Cancel As Integer)
Dim frmHeight As Integer
Dim frmWidth As Integer
frmHeight = GetSetting(appname:="MyApp", Section:="MyForm",
Key:="Height", Default:="800")
frmWidth = GetSetting(appname:="MyApp", Section:="MyForm",
Key:="Width", Default:="1600")
DoCmd.MoveSize , , frmWidth, frmHeight

End Sub

Private Sub cmdClose_Click()
Dim frmHeight As Integer
Dim frmWidth As Integer

frmHeight = Me.Form.InsideHeight
frmWidth = Me.Form.InsideWidth
SaveSetting appname:="MyApp", Section:="MyForm", Key:="Height",
setting:=frmHeight
SaveSetting appname:="MyApp", Section:="MyForm", Key:="Width",
setting:=frmWidth

End Sub

It works very well and almosts meets my exact requirements - except
for one thing - I cannot work out how to find the 'current' 'right'
and 'down' values that i would use with the docmd.MoveSize command.

Rgds and thanks again for time time and knowledge

Kiers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top