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.

Recommended Answers

All 2 Replies

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!

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.