Is there a way to view all the items in a collection in a form? For example, lets say that I wanted to have a list of all the controls on a given form and be able to set properties for those controls through the use of a form. Do I just need to loop through the collection and add the names of the controls to a temp table and then find the control name through a variable when I need to get to its properties? I kind of think that I know how to do this, but I've never done it before.
Seth,
The quick way of converting is to simply create a temporary table and insert every value of the collection into the table.
Of course, if I am reading what you are writing correctly, it seems that your intent is to have a list of existing controls, with a one-to-many relationship to the attributes for each of the controls. Perhaps it is best not to bother with a temporary table; instead, have two perminant tables with the associated forms already in the database - then when you want to edit properties for a specific control(s), simply insert the information into the existing tables.
What do you think?
Regards,
Oralloy
6 4322
Seth, I am a little confused as to the exact nature of your question, but I will give it a shot. The following Code will: - Loop through all Controls on a Form.
- Filter out only Command Buttons.
- Dynamically adjust their Widths based on a Scale Factor contained within a Text Box on a Form.
-
Dim ctl As Control
-
Dim sngScaleFactor As Single
-
-
If IsNull(Me![txtScale]) Then Exit Sub
-
-
sngScaleFactor = Me![txtScale]
-
-
'Need to set some Ranges on the Scale Value and if they are out of
-
'a specified Range, maintain the existing Width
-
If sngScaleFactor < 0.25 Or sngScaleFactor > 2 Then
-
sngScaleFactor = 1 'Maintain existing Width
-
End If
-
-
For Each ctl In Me.Controls
-
If ctl.ControlType = acCommandButton Then
-
ctl.Width = ctl.Width * sngScaleFactor
-
End If
-
Next
You can also manipulate a Control's Properties using a Variable referencing the Control: -
Dim strControlName As String
-
-
strControlName = "cmdSearch"
-
-
'Increase Control's Width by 50%
-
Me.Controls(strControlName).Width = Me.Controls(strControlName).Width * 1.5
Am I even close? (LOL).
You are sort of close :) What sparked this question is in learning SQL Server, I have learned that it has default system views that lets you query all kinds of information that is similar to information that Access has in collections. For example, I could run a query to find all the table names or the fields in a given table. Because I can query this, I can view this information in a form (continuous or datasheet). I looked at the system tables for Access and I can't find any information like a list of controls for a given form. So I was wondering if I could somehow convert a collection (such as Me.Controls) to recordset so that I can then view the data that is in the collection in a form and have a field that would allow me to change the tag property for instance. This would allow my users (who I have set as administrators) to edit some properties without having to touch VBA.
I hope this makes it clearer.
Seth,
The quick way of converting is to simply create a temporary table and insert every value of the collection into the table.
Of course, if I am reading what you are writing correctly, it seems that your intent is to have a list of existing controls, with a one-to-many relationship to the attributes for each of the controls. Perhaps it is best not to bother with a temporary table; instead, have two perminant tables with the associated forms already in the database - then when you want to edit properties for a specific control(s), simply insert the information into the existing tables.
What do you think?
Regards,
Oralloy
Okay. So it sounds looping through the collection and writing the names to a table is the way to go. I think that I can do that.
Thanks Oralloy.
You can write Code that will will populate a Table with the Names of all Forms as well as all the Controls associated with those Forms.
That is what I plan on doing.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: sci |
last post by:
Could someone help me by answering the questions below?
What's a cursor?
What's difference between Query and View?
Is a RecordSet just part of a table? Can it be part of a query of view?
If...
|
by: !TG |
last post by:
I currently use Do while loop, but I'd rather use a For Loop though I
have never gotten the hang of them.
Would some one please be so kind as to show me how to loop through a
recordset.
|
by: Neil |
last post by:
I previously posted re. this, but thought I'd try again with a summary of
facts.
I have an Access 2000 MDB with a SQL Server 7 back end. There is a view that
is linked to the database via ODBC...
|
by: Mika |
last post by:
Is it possible to perform functions on a recordset (rather than on the
source database), e.g. COUNT, MAX etc
The reason I would like to do this is because I have a hugely complex view
which...
|
by: Dom Boyce |
last post by:
Hi
First up, I am using MS Access 2002.
I have a database which records analyst rating changes for a list of
companies on a daily basis. Unfortunately, the database has been set
up (by my...
|
by: ano1optimist |
last post by:
Has anyone had success with using a command collection with parameters
to run a stored procedure from sql server? I'm frustrated and have
been spending way too much time trying to make this work. ...
|
by: Lyn |
last post by:
Hi,
This question may seem a bit academic...
To learn more about Access VBA, I have been enumerating the properties of
various form controls. This was mostly successful and I have learned a lot...
|
by: kjvt |
last post by:
Based on a prior posting, I've written a function to convert a
recordset to a dataview. The first call to the function for a given
recordset works perfectly, but the second call always returns a...
|
by: Rene Aichinger |
last post by:
Hi,
I've created a server control (it inherits from WebControl) wich has a
property of genertic collection type.
The type of the generic collection is NavigationItem, a little class I've...
|
by: Ed |
last post by:
hi everyone, maybe someone can give me a hand here.
I am working with vb 2005 and i have a gridview that i am loading data from a recordset. I have the recordset returned from the query and i am...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |