473,857 Members | 1,986 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Could someone point me in the right direction to use DAO to list all forms, their textboxes and two properties for each textbox?

MLH
I would like to populate a table with the following information:

tblPropertySett ings
[strFormName]
[strTextboxName]
[strOnGFprop] - the GotFocus property setting string
[strOnLFprop] - the LostFocus property setting string

I'd like to document the above info for all Forms and all Textbox
controls on each Form.

I would write it to debug window if it weren't for the fact that
there are too many lines & the immediate window's FIFO buffer
would roll excessive lines off the top. Therefore, I'm using a table.

Here's what I snatched from HELP so far...
Sub ListFields()
Dim dbs As Database, tdf As TableDef, fld As Field

' Return Database object variable pointing to current
database.
Set dbs = CurrentDb
' Return TableDef object variable pointing to Employees table.
Set tdf = dbs.TableDefs!E mployees
' Enumerate fields in Employees table.
For Each fld In tdf.Fields
Debug.Print fld.Name
Next fld
End Sub

I think what I need must go inside the for-next loop. Just don't know
what it is to be.
Jan 20 '06 #1
2 1701
Assuming Access 2000 or later, this first example shows how to get the names
of all forms in the database:

Function ShowAllForms()
Dim accobj As AccessObject
For Each accobj In CurrentProject. AllForms
Debug.Print accobj.Name
Next
End Function

This next example shows how to get at all the text boxes on the form, by
opening it in design view (hidden). Clearly you can call this funtion in the
loop above, so it is called for every form in your database:

Function ShowTextBoxes(s trFormName As String)
Dim frm As Form
Dim ctl As Control

DoCmd.OpenForm strFormName, acDesign, _
WindowMode:=acH idden
Set frm = Forms(strFormNa me)

For Each ctl In frm.Controls
If ctl.ControlType = acTextBox Then
Debug.Print ctl.Name
End If
Next

Set ctl = Nothing
Set frm = Nothing
DoCmd.Close acForm, strFormName
End Function

The final piece of your puzzle is to write these names into a table. Do do
that, open a recordset, and add new:
Dim rs As DAO.Recordset
Set rs = dbEngine(0)(0). OpenRecordset(" tblPropertySett ings",
dbOpenDynaset, dbAppendOnly)

rs.AddNew
rs!strFormName = strFormName
rs!TextboxName = ctl.Name
rs!stOnGFprop = ctl.OnGotFocus
rs!strOnLFprop = ctl.OnLostFocus
rs.Update

rs.Close

In practice, you will use the first 3 lines at the top of the ShowAllForms
code, and the last line at the end of that function. You will pass the
recordset variable to the ShowTextBoxes() procedure, and so the middle 6
lines will replace:
Debug.Print ctl.Name

Hope that all makes sense, step by step, and when you put it together.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"MLH" <CR**@NorthStat e.net> wrote in message
news:t6******** *************** *********@4ax.c om...
I would like to populate a table with the following information:

tblPropertySett ings
[strFormName]
[strTextboxName]
[strOnGFprop] - the GotFocus property setting string
[strOnLFprop] - the LostFocus property setting string

I'd like to document the above info for all Forms and all Textbox
controls on each Form.

I would write it to debug window if it weren't for the fact that
there are too many lines & the immediate window's FIFO buffer
would roll excessive lines off the top. Therefore, I'm using a table.

Here's what I snatched from HELP so far...
Sub ListFields()
Dim dbs As Database, tdf As TableDef, fld As Field

' Return Database object variable pointing to current
database.
Set dbs = CurrentDb
' Return TableDef object variable pointing to Employees table.
Set tdf = dbs.TableDefs!E mployees
' Enumerate fields in Employees table.
For Each fld In tdf.Fields
Debug.Print fld.Name
Next fld
End Sub

I think what I need must go inside the for-next loop. Just don't know
what it is to be.

Jan 20 '06 #2
On Fri, 20 Jan 2006 08:04:54 -0500, MLH <CR**@NorthStat e.net> wrote:

This code is for tables and fields. What you need is forms and
controls.
Pseudo code:
for each form in the Docuements collection
open form in design view
for each control in the form's Controls collection
if TypeOf control is TextBox then
inspect properties
write to table
end if
next
close form
next

-Tom.

I would like to populate a table with the following information:

tblPropertySet tings
[strFormName]
[strTextboxName]
[strOnGFprop] - the GotFocus property setting string
[strOnLFprop] - the LostFocus property setting string

I'd like to document the above info for all Forms and all Textbox
controls on each Form.

I would write it to debug window if it weren't for the fact that
there are too many lines & the immediate window's FIFO buffer
would roll excessive lines off the top. Therefore, I'm using a table.

Here's what I snatched from HELP so far...
Sub ListFields()
Dim dbs As Database, tdf As TableDef, fld As Field

' Return Database object variable pointing to current
database.
Set dbs = CurrentDb
' Return TableDef object variable pointing to Employees table.
Set tdf = dbs.TableDefs!E mployees
' Enumerate fields in Employees table.
For Each fld In tdf.Fields
Debug.Print fld.Name
Next fld
End Sub

I think what I need must go inside the for-next loop. Just don't know
what it is to be.


Jan 20 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
1284
by: guy | last post by:
Has anyone any experience of building a form at run time? I have an app that will require 50+ simple forms, it will only be used by me, so appearance isnt important. My idea is to pass a business object to a standard form and use reflexion to determine what controls are needed, maybe using custom attributes to help this. any thoughts?
2
1364
by: BryanEverly | last post by:
Hi, I'm struggling with a problem and was hoping that someone on this group could point me in the right direction. I'm not looking for a free ride, just a suggestion as to how best to use all the tools at my disposal to diagnose the situation. I have an existing COM+ / ASP application (the COM+ objects are written in VB 6.0) that I am wanting to migrate forward to .NET (using VB.Net). I have added some ASPX pages to the existing...
7
2102
by: MLH | last post by:
Building Applications with Microsoft Access 97 is a publication I think I need. Is it available in book form? Is MicroSoft the sole vendor? Anybody got a copy they wanna sell???
4
2680
by: Kathy | last post by:
I have a form to generate a report. On the form are several textboxes and a "Generate" button. I would like to have the button grayed (not enabled), unless the data in each of the dependant textboxes is valid. What is the proper procedure for doing this? It seems the Validating and Validated events for each control only fire when it loses focus. I would like the button to be enabled as soon as the data is valid (before leaving the...
2
1490
by: Jason | last post by:
I want to loop through all textbox controls to determine their .text value. If the .text value is not "" then display the textbox. I have tried the following with no luck. Any help would be appreciated. Dim ctrl as Control For Each ctrl in Page.Controls If ctrl.GetType.ToString
1
1193
by: Andy Sutorius | last post by:
Hi, Setup/History: Code-behind = C#. I have created an html table with textboxes in each cell dynamically with asp.net. The number of rows depends on what the datareader brings back. The columns (6 of them) are static. After the table is built I take a snapshot of the names of the textboxes and the values inside them (before the values of the textboxes are altered by humans). I need to use this snapshot/data after the webpage has been...
7
6792
by: Brad | last post by:
I have several labels and textboxes that are drawn to a tab page based on certain criteria so these labels and textboxes can be drawn at different points on the tab page. I set the label and textbox names in the drawing procedure. Now what I need to do is to get the control's information on a mouse down. Here is what I have: //// Private Sub tcGuard_MouseDown(ByVal sender as Object, ByVal e as
9
6775
by: Edwinah63 | last post by:
Hi everyone, Please let there be someone out there who can help. I have two BOUND combo boxes on a continuous form, the second being dependent on the first. I have no problem getting the second combo to change depending on what values the user selects in the first box, it's just that every time the user changes the first combobox, the second combobox FOR EVERY RECORD goes blank.
5
1717
by: BLACKDOG157 | last post by:
I've made a form with a variable number of textboxes. The user fills them out, and then I need to pick up the values he has filled in. The number of textboxes vary depending on a value that the user filled in in another page. But suppose there were 3 values. In that case, I know the names of the fields, they are MyTextBox1 MyTextbox2 MyTextbox3
0
9923
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9767
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10709
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10806
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10394
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7939
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7104
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5967
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4592
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.