By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,071 Members | 1,188 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,071 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
You have the patience of Job, Allen.

Feb 15 '06 #3

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.