1,105,263 Community Members

Access 2007

Member Avatar
tranquil
Newbie Poster
3 posts since Oct 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi, I am developing database in Access & VB. My question is how can forms be displayed so that they automatically size to any screen whether it be 15" or 21", for example. Many thanks.

Member Avatar
BitBlt
Practically a Posting Shark
895 posts since Feb 2011
Reputation Points: 442 [?]
Q&As Helped to Solve: 163 [?]
Skill Endorsements: 16 [?]
Featured
 
0
 

Just code up something to adjust the sizes/positions of the controls in the form_resize event procedure. You'll probably have to do some deciding about what has to stretch vertically/horizontally (like grids or text boxes) and what has to stretch in one direction only (lists or single-line text boxes) and what just has to reposition (command buttons or frames). It's tedious, but once you get it right the effect is worth it to your user.

Here's some sample code to give you a flavor:

Private Sub Form_Resize()
' Sets minimum dimensions
If Me.InsideHeight < 2000 Then
    Me.InsideHeight = 2000
End If
If Me.InsideWidth < 6000 Then
    Me.InsideWidth = 6000
End If

' Reposition a command button
Me.cmdApplyChanges.Left = Me.InsideWidth - Me.cmdApplyChanges.Width - 100

' resize the form section so everything else will fit
Me.Section(0).Height = Me.InsideHeight
Me.cmdApplyChanges.Top = Me.InsideHeight - Me.cmdApplyChanges.Height - 200 - Me.cmdClose.Height - 650
Me.cmdClose.Left = Me.cmdApplyChanges.Left
Me.cmdClose.Top = Me.cmdApplyChanges.Top + Me.cmdApplyChanges.Height + 50
' scale a grid to fill up the available space
Me.gridSchedule.Width = Me.InsideWidth - Me.cmdApplyChanges.Width - 400
Me.gridSchedule.Height = Me.InsideHeight - Me.Frame11.Height - 500
End Sub

Hope this helps!

Member Avatar
tranquil
Newbie Poster
3 posts since Oct 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Many thanks for your quick response - very excited to see how it works. I will give this a go over the next week or so and will let you know. Again thank you.:)

Just code up something to adjust the sizes/positions of the controls in the form_resize event procedure. You'll probably have to do some deciding about what has to stretch vertically/horizontally (like grids or text boxes) and what has to stretch in one direction only (lists or single-line text boxes) and what just has to reposition (command buttons or frames). It's tedious, but once you get it right the effect is worth it to your user.

Here's some sample code to give you a flavor:

Private Sub Form_Resize()
' Sets minimum dimensions
If Me.InsideHeight < 2000 Then
    Me.InsideHeight = 2000
End If
If Me.InsideWidth < 6000 Then
    Me.InsideWidth = 6000
End If

' Reposition a command button
Me.cmdApplyChanges.Left = Me.InsideWidth - Me.cmdApplyChanges.Width - 100

' resize the form section so everything else will fit
Me.Section(0).Height = Me.InsideHeight
Me.cmdApplyChanges.Top = Me.InsideHeight - Me.cmdApplyChanges.Height - 200 - Me.cmdClose.Height - 650
Me.cmdClose.Left = Me.cmdApplyChanges.Left
Me.cmdClose.Top = Me.cmdApplyChanges.Top + Me.cmdApplyChanges.Height + 50
' scale a grid to fill up the available space
Me.gridSchedule.Width = Me.InsideWidth - Me.cmdApplyChanges.Width - 400
Me.gridSchedule.Height = Me.InsideHeight - Me.Frame11.Height - 500
End Sub

Hope this helps!

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: