Basic Coding Question - Where should I paste these codes?

  • Thread starter Thread starter K90267000 via AccessMonster.com
  • Start date Start date
K

K90267000 via AccessMonster.com

Hi all,
I am a newbie to using ACCESS 2007.
From the ACCESS HELP contents, I found something (procedure?) I wanted (see
bottom)
Its function is to..."use the InsideHeight property to determine the height
and width of the window containing a form"

May I ask.....Where should I paste the codes?
Thanks very much!


Codes :
Sub ResetWindowSize(frm As Form)
Dim intWindowHeight As Integer
Dim intWindowWidth As Integer
Dim intTotalFormHeight As Integer
Dim intTotalFormWidth As Integer
Dim intHeightHeader As Integer
Dim intHeightDetail As Integer
Dim intHeightFooter As Integer

' Determine form's height.
intHeightHeader = frm.Section(acHeader).Height
intHeightDetail = frm.Section(acDetail).Height
intHeightFooter = frm.Section(acFooter).Height
intTotalFormHeight = intHeightHeader _
+ intHeightDetail + intHeightFooter
' Determine form's width.
intTotalFormWidth = frm.Width
' Determine window's height and width.
intWindowHeight = frm.InsideHeight
intWindowWidth = frm.InsideWidth

If intWindowWidth <> intTotalFormWidth Then
frm.InsideWidth = intTotalFormWidth
End If
If intWindowHeight <> intTotalFormHeight Then
frm.InsideHeight = intTotalFormHeight
End If
End Sub
 
Create a module (not a class module, nor the module associated with a form)
and copy that code into the new module. Make sure you do not name the module
ResetWindowSize (modules cannot be named the same as subs or functions)

From the form where you want to invoke that code, you'd call the routine as:

ResetWindowSize Me

or

Call ResetWindowSize(Me)
 
Thanks douglas for your reply,
I have pasted the codes in a module called Module1.
However, I am still unsure where to call the rountine from...
I tried calling from On Current....
Private Sub Form_Current()
ResetWindowSize Me
End Sub
It won't work.
I then tried to call from On Load, On Open, On Reisze, still won't work.

May I know, where should I call the rountine?

Thanks!
Create a module (not a class module, nor the module associated with a form)
and copy that code into the new module. Make sure you do not name the module
ResetWindowSize (modules cannot be named the same as subs or functions)

From the form where you want to invoke that code, you'd call the routine as:

ResetWindowSize Me

or

Call ResetWindowSize(Me)
Hi all,
I am a newbie to using ACCESS 2007.
[quoted text clipped - 37 lines]
End If
End Sub
 
Are you sure that the Form_Current event code is actually running?


I make no pretense of checking that the ResetWindowSize code works...

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


K90267000 via AccessMonster.com said:
Thanks douglas for your reply,
I have pasted the codes in a module called Module1.
However, I am still unsure where to call the rountine from...
I tried calling from On Current....
Private Sub Form_Current()
ResetWindowSize Me
End Sub
It won't work.
I then tried to call from On Load, On Open, On Reisze, still won't work.

May I know, where should I call the rountine?

Thanks!
Create a module (not a class module, nor the module associated with a
form)
and copy that code into the new module. Make sure you do not name the
module
ResetWindowSize (modules cannot be named the same as subs or functions)

From the form where you want to invoke that code, you'd call the routine
as:

ResetWindowSize Me

or

Call ResetWindowSize(Me)
Hi all,
I am a newbie to using ACCESS 2007.
[quoted text clipped - 37 lines]
End If
End Sub
 
Thanks for your reply douglas,
Maybe this is beyond me...phew.. :)
Is there a way i can find out if its running?
I opened the form, does that mean that Form_Current event code will be run ?
Thanks for any help


Are you sure that the Form_Current event code is actually running?

I make no pretense of checking that the ResetWindowSize code works...
Thanks douglas for your reply,
I have pasted the codes in a module called Module1.
[quoted text clipped - 30 lines]
 
You can set a breakpoint in the code (you click on the margin to the left of
the statement), or you can put a message box in the code. If the message box
doesn't appear, you can assume the code isn't running.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


K90267000 via AccessMonster.com said:
Thanks for your reply douglas,
Maybe this is beyond me...phew.. :)
Is there a way i can find out if its running?
I opened the form, does that mean that Form_Current event code will be run
?
Thanks for any help


Are you sure that the Form_Current event code is actually running?

I make no pretense of checking that the ResetWindowSize code works...
Thanks douglas for your reply,
I have pasted the codes in a module called Module1.
[quoted text clipped - 30 lines]
End If
End Sub
 
Back
Top