Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Report Parameters with VB Code 2

Status
Not open for further replies.

Vidar13

IS-IT--Management
Apr 4, 2001
90
0
0
US
I have a report that I want to be able to change the layout via code, from data supplied from a table. I'm trying to change the top/left positing of the report fields on the fly to meet the demands specified in a parameter table.

It doesn't appear there are any field positioning controls that are available in the report load event?? Is there another way to go about this?
 
on the format event of the report try something like this

Me.Controls("Name of Control").Left = 100

you can use any of the properties that you normally would be able to use for the control type( ie top, left, height, width). the unit used for the properties are in twips, so you probably will have to convert the values. for cm it's 567 twips in 1 cm. only limitation is you can't change the height or width of the report section the fly.
 
If you only need to position the controls once, you should put the code in the Report_Open event. If you need to move them around depending upon the data within the report, you put the code in the _Format section for the controls.

Example: Me.controlname.Top = 0

You can also change the height of the sections in the Report_Open. If you make them smaller than what's on the layout, all the controls must fit within the decreased height. If they don't, Access doesn't give an error. Instead, it uses the minimum possible height that will contain all the controls.
 
Cool! That works. Now, does anyone know how many twips there are in an inch?
 
Nevermind.. I see that it's 1440 twips per inch.
Thanks for your help. Everything works perfectly now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top