 |
| Access VBA Discuss using VBA for Access programming. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

December 20th, 2006, 09:41 AM
|
|
Friend of Wrox
|
|
Join Date: Sep 2003
Posts: 155
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Form resize at runtime
Hi, dunno if this is even do-able in code, but expect it is, thoughI need something simple otherwise I will be looking at other methods.
I need to resize the Switchboard form. I have a command button which will act as a toggle (but is not a toggle!) and the butto will resize a few objects but will also set the form width to X or Y, dependant on other settings.
The form was designed with size X.
The form does change to size Y when the button is click, which I can tell by Window>SizeToFit, but I cannot find anything to do the resize for me!!!
Have tried allsorts, refresh, repaint, docmd.runcommand accmdSizeToFit (err 2046, since this is not an option available!!!)...
Anyone, anyone, anyone?
|
|

December 21st, 2006, 09:18 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
If you have a threshhold for the screen size at which you would like to change the form size for the user (I am assuming this is your aim), then on the Form's On Open event, check the screen resolution and resize when your threshhold is crossed:
'---------------------------------
Dim sComp As String
Dim iHoriz, iVert As Integer
sComp = "."
Set objWMIService = GetObject("winmgmts:\\" & sComp & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_VideoController")
For Each objItem In colItems
If objItem.CurrentHorizontalResolution <> "" Then
iHoriz = objItem.CurrentHorizontalResolution
End If
If objItem.CurrentVerticalResolution <> "" Then
iVert = objItem.CurrentVerticalResolution
End If
Next
If iHoriz < 1024 And iVert < 768 Then
frm.Section(acHeader).Height = ?
frm.Section(acDetail).Height = ?
frm.Section(acFooter).Height = ?
frm.Width = ?
End If
Does that help?
mmcdonal
|
|

December 21st, 2006, 09:19 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
Sorry, add this:
'-------------------------
If iHoriz < 1024 And iVert < 768 Then
frm.Section(acHeader).Height = ?
frm.Section(acDetail).Height = ?
frm.Section(acFooter).Height = ?
frm.Width = ?
Else
frm.Section(acHeader).Height = ?
frm.Section(acDetail).Height = ?
frm.Section(acFooter).Height = ?
frm.Width = ?
End If
'---------------------------------
mmcdonal
|
|

December 21st, 2006, 09:20 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
Whoops:
'------------------------------
If iHoriz <= 1024 And iVert <= 768 Then
frm.Section(acHeader).Height = ?
frm.Section(acDetail).Height = ?
frm.Section(acFooter).Height = ?
frm.Width = ?
Else
frm.Section(acHeader).Height = ?
frm.Section(acDetail).Height = ?
frm.Section(acFooter).Height = ?
frm.Width = ?
End If
'--------------------------
mmcdonal
|
|

December 21st, 2006, 09:35 AM
|
|
Friend of Wrox
|
|
Join Date: Sep 2003
Posts: 155
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
No, it is to resize a form during its usage rather than in the Open or Load... so I have a form (the Switchboard, frankly!) and I want to display some "dashboard" data on it, but I don't think the user will always want the data on the screen, so I have given them a button in the top right hand corner, that they click... it then (hopefully) expands the width of the form to show the "dashboard" stats. And I need to narrow the width when they are done, ie: lose focus, click close or something else.
I dont think it is easily doable, so will probably leave it out.. or use a pop-up, boo!
I can do the resize but I cant refresh the form on the screen to show the new width! So the form is resizing, but only in design view! Grrr. I have tried maximise and then restore to no joy, and also the RunCommand.acCmdSizeToFit, but this command throws a 2046 (Command not available!) as soon as the resize happens, and only when the resize happens! Think it may need fax confirmation of the new width or something???
|
|
 |