473,395 Members | 1,530 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,395 software developers and data experts.

Seeking code to ID & print all controls having a ValidationRule property set - but no ValidationText

MLH
Seeking code to ID & print all controls on all forms having a
ValidationRule property set - but no ValidationText property
setting. Perhaps some modification of the following procedure
would do it?

Private Sub ListControlsBttn_Click()
'************************************************* ************************
' Purpose: Run the Controls Collection for user-specified form.
' The controls collection is a form's default collection.
'************************************************* ************************
On Error GoTo ListControlsBttn_ClickError
Dim ThisForm As String
ThisForm = Me.Name
Dim i As Integer, intHowmany As Integer, WhichForm As String

Msg = "Enter form name." ' Set prompt.
Title = "Form Name?" ' Set title.
Defvalue = "frmListThings" ' Set default return value.
WhichForm = InputBox$(Msg, Title, Defvalue) ' Get user input.
If WhichForm = "" Then Exit Sub
For i = 0 To Forms(WhichForm).Count - 1
intHowmany = intHowmany + 1
Debug.Print intHowmany; ") "; Forms(WhichForm)(i).Name
Next i

ExitButton11_Click:
Exit Sub

ListControlsBttn_ClickError:
Dim r As String, k As String, Message3 As String
r = "The following unexpected error occurred in Sub
ListControlsBttn_Click, CBF on " & ThisForm & "."
k = CRLF & CRLF & "Error # " & Trim$(str$(Err)) & ": " & Quote &
Error$ & Quote
Message3 = r & k
MsgBox Message3, vbExclamation, "Unexpected Error - " & MyApp$ &
", rev. " & MY_VERSION$
Resume ExitButton11_Click

End Sub

Feb 15 '06 #1
4 1417
Perhaps something like this, if you are using Access 2000 or later:

Function FindRuleText()
Dim accobj As AccessObject
Dim ctl As Control
Dim strDoc As String

For Each accobj In CurrentProject.AllForms
strDoc = accobj.Name
DoCmd.OpenForm strDoc, acDesign, WindowMode:=acHidden
For Each ctl In Forms(strDoc).Controls
If HasProperty(ctl, "ValidationRule") Then
If (ctl.ValidationRule <> vbNullString) And
(ctl.ValidationText = vbNullString) Then
Debug.Print strDoc & "." & ctl.Name
End If
End If
Next
DoCmd.Close acForm, strDoc
Next
End Function
Public Function HasProperty(obj As Object, strPropName As String) As Boolean
'Purpose: Return true if the object has the property.
Dim varDummy As Variant
On Error Resume Next
varDummy = obj.Properties(strPropName)
HasProperty = (Err.Number = 0)
End Function

--
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:hk********************************@4ax.com...
Seeking code to ID & print all controls on all forms having a
ValidationRule property set - but no ValidationText property
setting. Perhaps some modification of the following procedure
would do it?

Feb 15 '06 #2
You have the patience of Job, Allen.

Feb 15 '06 #3
MLH
I'll have a go at this in A97. Thx 4 suggestion.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

On Thu, 16 Feb 2006 00:46:41 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote:
Perhaps something like this, if you are using Access 2000 or later:

Function FindRuleText()
Dim accobj As AccessObject
Dim ctl As Control
Dim strDoc As String

For Each accobj In CurrentProject.AllForms
strDoc = accobj.Name
DoCmd.OpenForm strDoc, acDesign, WindowMode:=acHidden
For Each ctl In Forms(strDoc).Controls
If HasProperty(ctl, "ValidationRule") Then
If (ctl.ValidationRule <> vbNullString) And
(ctl.ValidationText = vbNullString) Then
Debug.Print strDoc & "." & ctl.Name
End If
End If
Next
DoCmd.Close acForm, strDoc
Next
End Function
Public Function HasProperty(obj As Object, strPropName As String) As Boolean
'Purpose: Return true if the object has the property.
Dim varDummy As Variant
On Error Resume Next
varDummy = obj.Properties(strPropName)
HasProperty = (Err.Number = 0)
End Function


Feb 16 '06 #4
A97 does not have the AllForms collection.

To loop through the names of the forms, OpenRecordset on:
SELECT [Name] FROM MsysObjects
WHERE (([Type] = -32768) AND ([Name] Not Like '~*'))
ORDER BY MsysObjects.Name;

--
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:5a********************************@4ax.com...
I'll have a go at this in A97. Thx 4 suggestion.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

On Thu, 16 Feb 2006 00:46:41 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote:
Perhaps something like this, if you are using Access 2000 or later:

Function FindRuleText()
Dim accobj As AccessObject
Dim ctl As Control
Dim strDoc As String

For Each accobj In CurrentProject.AllForms
strDoc = accobj.Name
DoCmd.OpenForm strDoc, acDesign, WindowMode:=acHidden
For Each ctl In Forms(strDoc).Controls
If HasProperty(ctl, "ValidationRule") Then
If (ctl.ValidationRule <> vbNullString) And
(ctl.ValidationText = vbNullString) Then
Debug.Print strDoc & "." & ctl.Name
End If
End If
Next
DoCmd.Close acForm, strDoc
Next
End Function
Public Function HasProperty(obj As Object, strPropName As String) As
Boolean
'Purpose: Return true if the object has the property.
Dim varDummy As Variant
On Error Resume Next
varDummy = obj.Properties(strPropName)
HasProperty = (Err.Number = 0)
End Function

Feb 16 '06 #5

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

Similar topics

5
by: MLH | last post by:
Having identified a A97 bug in which acDialog causes undesirable side effects processing the opened form, I would like to replace the following code running in MyForm ... DoCmd.OpenForm...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
7
by: Donald Grove | last post by:
Is it possible to retrieve field properties from a table in access2000 using code? I have tried: " dim dbs as dao.database dim tbl as dao.tabledef dim fld as dao.field dim prop as...
3
by: CDMAPoster | last post by:
A.K.A. Is Double Dating a bad thing :-)? My post from several hours ago may have gotten lost so please forgive me if something similar to this shows up twice. From a modular programming class I...
3
by: Ronald S. Cook | last post by:
I'm developing a Windows application that will have an ListBar like in Outlook. When the user clicks on a ListBar item, I would like to load the associated User Control. The below code works...
1
by: Ajak | last post by:
Hi all, I would like to write a class (Task) with a method to do some lengthy process based on several of the class properties. The method is running on different thread. During the execution...
8
by: Greg (codepug | last post by:
For lack of the proper expression, how do I excite a control to cause events to trigger. I have a date control and am using a calender form button to fill the text box with the date. The text box...
9
by: dhtml | last post by:
I have written an article "Unsafe Names for HTML Form Controls". <URL: http://jibbering.com/faq/names/ > I would appreciate any reviews, technical or otherwise. Garrett --...
0
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...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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,...
0
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...
0
Oralloy
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,...
0
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...
0
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...

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.