I have complete my form to use around the office, however, when opened on different computers the form doesnt resize.Instead, the scroll bar appears. How can i make the form and controls automatically resize ?
相关问题
- Error handling only works once
- Excel formula in VBA code
- Excel VBA run time error 450 from referencing a ra
- DoCmd.TransferSpreadsheet is not recognizing works
- VBA Self-Function returns #VALUE! Error on cell, w
相关文章
- Unregister a XLL in Excel (VBA)
- numeric up down control in vba
- Declare a Range relative to the Active Cell with V
- How to disable changes in a cell using vba?
- MsgBox Yes/No Excel VBA
- Rounding up to nearest higher integer in VBA
- Deleting columns from a table with merged cells
- Convert range to comma delimited string
A few notes:
Have a look at how to anchor controls to the form so they can resize with the form.
Design your forms so they display properly on the smallest screensize that your users have.
It's important that you think about how your users will interact with your application. You cannot expect Access to magically reflow and resize everything, it's something you, as the designer of the application, need to think about.
So limit the number of controls on your form, and keep them small enough that they display correctly on whatever is the smallest reasonable screen resolution in your office.
If you do not want bars to appear, look at the form's
scrollbars
properties.Look into the various form styles you can use: in Access 2007 and above, you can use forms in tabs. You can also make them popup, and prevent them from being resized.
Look into the following form properties and play around the various combinations to get the desired effect:
Here is some VBA code you could add to your form that will keep the form looking the same no matter how large or small the user has made the window on their monitor or what their monitor resolution is.
Also you can make the text larger or smaller by holding the Ctrl key and scrolling the mouse wheel up and down (or, alternatively, holding the Shift key and hitting the + key or the - key.)
To use this functionality, just open Access and open your form in design view. First, right-click on the image of the form and add the
Form Header/Footer
.If you don't add the header and footer to the form, the code below will error out. However, you can shrink the height of both the header and the footer to nothing if you don't want them to appear on your form.
Select the Form itself by clicking the little box at the top left of the form, just below the tab:
This will make sure we are looking at the properties for the form itself when we view the
Property Sheet
.To view the
Property Sheet
for the form (if it isn't visible already), hold the Alt key and press the Enter key.Choose the
Event
tab.You'll then need to add the literal text
[Event Procedure]
to the following five events behind the form itself:You can either type the literal text
[Event Procedure]
into the text box next to these events, or click the ellipsis (...) button next to each event and chooseCode Builder
from the pop up menu.It will look something like this:
...
...
...
...
Also, at the bottom of the list of events, you'll also need to change the
Key Preview
property toYes
:Finally, you'll probably want to turn
Scroll Bars
off on the form so that they don't overlap any content. To do this, go to theFormat
tab of theProperty Sheet
for your form in design view and change theScroll Bars
property toNeither
.Now, to add the VBA code, hold Alt and hit F11 to view the VBA editor.
Once inside the VBA editor, double click on the
Form_YourFormName
option under theMicrosoft Access Class Objects
folder:If you do not see the
Microsoft Access Class Objects
folder, then go back to the form in design view and click the ellipsis (...) next to the literal text[Event Procedure]
on any of the events you just modified.This will take you back to the VBA editor and you should now be inside the
Form_YourFormName
code area. There will already be some code there, but you can erase all of it before proceeding to the next step.Then in the main part of the screen on the right, just copy and paste the code below and you're done.
Here are some screenshots of what a form looks like when shrunk.
Before:
After:
Also, you can make the text larger by holding the Ctrl key and scrolling the mouse wheel up (or, alternatively by holding the Shift key and pressing the + key.)
And, you can make the text smaller by holding the Ctrl key and scrolling the mouse wheel down (or, alternatively by holding the Shift key and pressing the - key.)