I'm building forms and reports using Mircrosoft Access. I've ran into this issue a few times now and I'm tired of working around it. I need to be able to move objects by changing the left and top position in an access report/form. This is an example of my code. I've tried declaring variables as variant, long, integer, and double. Should I just keep rotating through the different types or is there a better way of doing this? When the form/report opens, the object just goes to zero and the value shown in properties is "0.0028"
Public Sub Form_Load()
Dim lngTop As Long
Dim lngLeft As Long
lngTop = 4.4
lngLeft = 4.4
With Forms!frmTest!Label0
.Left = 4.4
.Top = 4.4
End With
End Sub
You need to use twips as the unit of measurement.
There are 567 twips per cm
There are 1440 twips per inch.
Assuming you are using English measurements, for clarity I tend to use code like this:- -
Public Sub Form_Load()
-
Const TwipsPerInch = 1440
-
-
With Forms!frmTest!Label0
-
.Left = 4.4 * TwipsPerInch
-
.Top = 4.4 * TwipsPerInch
-
End With
-
End Sub
-
Phil
8 4111
You need to use twips as the unit of measurement.
There are 567 twips per cm
There are 1440 twips per inch.
Assuming you are using English measurements, for clarity I tend to use code like this:- -
Public Sub Form_Load()
-
Const TwipsPerInch = 1440
-
-
With Forms!frmTest!Label0
-
.Left = 4.4 * TwipsPerInch
-
.Top = 4.4 * TwipsPerInch
-
End With
-
End Sub
-
Phil
Thanks PhilOfWalton. I've been doing dba stuff for 7/8 years and never heard of this. Thanks for the help.
Oh fail. Is there a way to make the changes on said form/report permanent?
How confusing!!!
Your original question was about dynamically moving a control as the form opened (Incidentally, I think it might be better to run the code on the OnOpen event rather than the OnLoad event)
Your second question asks how to position the control permanently.This, as I'm sure you are well aware, is done in Design View (Positionig here is done in Inches or Cms. - NOT Twips) and you don't need the code.
Am I missing the point of your question?
Phil
I apologize. I have about 800 objects on a single report. they are in sets of 4. and the position of each set is determined by 1 of those 4. I am unsure of how much time I've spent moving every single object and if I were to use a loop to position each set accordingly, it'd save me days.
Just a quick pic fo the dashboard with the kajillion objects.
That looks fun.
This bit of code may give you a clue to redesigning forms/reports.
Note that it is run from an individual module. -
Function RedesignReport(ReportName As String)
-
-
Const TwipsPerCm = 567
-
-
DoCmd.OpenReport ReportName, acViewDesign
-
-
With Reports(ReportName)
-
.Text2.Top = 2 * TwipsPerCm
-
.Text2.Left = 2 * TwipsPerCm
-
End With
-
-
DoCmd.Close acReport, ReportName
-
-
End Function
-
I presume you are aware that if your controls have a consistent form of naming like "loom0101", "loom0102" etc., you can refer to them using indexes.
if you have integers i & j then for i = 1 and j = 2, "loom0102" can be addressed as -
Me.Controls("loom" & Cstr(Format (i,"00")) & Cstr(Format (j,"00"))
-
Might give you the option to create a table to build your form
Phil
Thanks a bunch. I'll have to look into it some more but just being able to move the objects for now is weight lifted off of my shoulders. When I get the 1st version out, I'll start playing around with the module and let you know how it goes. Thanks again.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Chinook |
last post by:
Using code objects?
===================
As an OO exercise I have a factory pattern that returns class objects that
each have an "action" method. ClassObj.action() in turn returns a code
object...
|
by: Himaxda0 |
last post by:
Is it possible to access Objects like (document.form1.textfield1) with
a string variable like (var obName='textfield1') and using
(document.form1.obName.value)?
Ive tried it in IE but the value in...
|
by: Dixie |
last post by:
Is it possible to use VBA to turn off the View Hidden objects and System
objects?
dixie
|
by: Robson Machado |
last post by:
Dear friens,
Does anybody knows how to move controls (images, textboxes, buttons, etc..) using CodeBehind?
Regards,
|
by: Steve Schroeder |
last post by:
See: http://support.microsoft.com/default.aspx?scid=kb;en-us;317719
I can convert the sample code to my needs for the most part, where I'm fuzzy
on is:
...
|
by: rdemyan via AccessMonster.com |
last post by:
Is there a way, in code, to move a shelled application on the screen. I've
got the shelled app to open and it centers itself. I would like to move it
to the right using code, but I don't know...
|
by: ApexData |
last post by:
Hello
I currently Link the FE/BE using the LinkTables Option and the Linked
Table Manager. Any time I need to move the BE to another location, I
have to go through this process over again. I...
|
by: hypeartist |
last post by:
I need to create interface "on-the-fly" so it "reflects" some class (mainly it's properties). Here's how I do this:
public class Transformer
{
private const TypeAttributes...
|
by: Veloz |
last post by:
Hiya
My question is whether or not you should associated related objects in
your software using a scheme of id's and lookups, or wether objects
should actually hold actual object references to...
|
by: billw1100 |
last post by:
Hi, this is my first post here, so I hope I'm doing it right.
After converting an Access 2007 accdb database to accde, the vba code in my modules runs OK, but the code in my class objects (forms)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| | |