473,322 Members | 1,614 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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:

tblPropertySettings
[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!Employees
' 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 1662
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(strFormName As String)
Dim frm As Form
Dim ctl As Control

DoCmd.OpenForm strFormName, acDesign, _
WindowMode:=acHidden
Set frm = Forms(strFormName)

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("tblPropertySettings" ,
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**@NorthState.net> wrote in message
news:t6********************************@4ax.com...
I would like to populate a table with the following information:

tblPropertySettings
[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!Employees
' 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**@NorthState.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:

tblPropertySettings
[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!Employees
' 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
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...
2
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...
7
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
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...
2
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...
1
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...
7
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...
9
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...
5
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
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 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.