Connecting Tech Pros Worldwide Help | Site Map

More earth-shattering VBA code

DFS
Guest
 
Posts: n/a
#1: Dec 12 '06
'Search all reports for a text box named something

Dim cMsg As String, db As Database, rs As Recordset, rpt As Report, ctl as
Control
Set db = CurrentDb()
cMsg = "BuildingID"

Set rs = db.OpenRecordset("SELECT [NAME] AS REPORTOBJ FROM MSYSOBJECTS
WHERE [TYPE] = -32764;")
Do Until rs.EOF
DoCmd.openReport rs("REPORTOBJ"), acViewDesign, , , acHidden
Set rpt = Reports(rs("REPORTOBJ"))
For Each ctl In rpt.Controls
If ctl.ControlType = acTextBox Then
If ctl.Name = cMsg Then
Debug.Print "Report: " & rpt.Name & " contains " & cMsg
Exit For
End If
End If
Next ctl
Set rpt = Nothing
DoCmd.Close acReport, rs("REPORTOBJ"), acSaveNo
rs.MoveNext
Loop

rs.Close
Set rs = Nothing
MsgBox "Finished checking reports for " & cMsg



Larry Linson
Guest
 
Posts: n/a
#2: Dec 12 '06

re: More earth-shattering VBA code


Are you just sharing with us, or do you have a question? Generally, people
don't just post VBA code without some explanation.

Larry Linson

"DFS" <nospam@dfs_.comwrote in message
news:ySrfh.7922$Zz2.2862@bignews3.bellsouth.net...
Quote:
'Search all reports for a text box named something
>
Dim cMsg As String, db As Database, rs As Recordset, rpt As Report, ctl as
Control
Set db = CurrentDb()
cMsg = "BuildingID"
>
Set rs = db.OpenRecordset("SELECT [NAME] AS REPORTOBJ FROM MSYSOBJECTS
WHERE [TYPE] = -32764;")
Do Until rs.EOF
DoCmd.openReport rs("REPORTOBJ"), acViewDesign, , , acHidden
Set rpt = Reports(rs("REPORTOBJ"))
For Each ctl In rpt.Controls
If ctl.ControlType = acTextBox Then
If ctl.Name = cMsg Then
Debug.Print "Report: " & rpt.Name & " contains " & cMsg
Exit For
End If
End If
Next ctl
Set rpt = Nothing
DoCmd.Close acReport, rs("REPORTOBJ"), acSaveNo
rs.MoveNext
Loop
>
rs.Close
Set rs = Nothing
MsgBox "Finished checking reports for " & cMsg
>
>
>

DFS
Guest
 
Posts: n/a
#3: Dec 12 '06

re: More earth-shattering VBA code


Just sharing a handy snippet.


Larry Linson wrote:
Quote:
Are you just sharing with us, or do you have a question? Generally,
people don't just post VBA code without some explanation.
>
Larry Linson
>
"DFS" <nospam@dfs_.comwrote in message
news:ySrfh.7922$Zz2.2862@bignews3.bellsouth.net...
Quote:
>'Search all reports for a text box named something
>>
>Dim cMsg As String, db As Database, rs As Recordset, rpt As Report,
>ctl as Control
>Set db = CurrentDb()
>cMsg = "BuildingID"
>>
>Set rs = db.OpenRecordset("SELECT [NAME] AS REPORTOBJ FROM
>MSYSOBJECTS WHERE [TYPE] = -32764;")
>Do Until rs.EOF
>DoCmd.openReport rs("REPORTOBJ"), acViewDesign, , , acHidden
>Set rpt = Reports(rs("REPORTOBJ"))
> For Each ctl In rpt.Controls
> If ctl.ControlType = acTextBox Then
> If ctl.Name = cMsg Then
> Debug.Print "Report: " & rpt.Name & " contains " & cMsg
> Exit For
> End If
> End If
> Next ctl
>Set rpt = Nothing
>DoCmd.Close acReport, rs("REPORTOBJ"), acSaveNo
>rs.MoveNext
>Loop
>>
>rs.Close
>Set rs = Nothing
>MsgBox "Finished checking reports for " & cMsg

David F Cox
Guest
 
Posts: n/a
#4: Dec 13 '06

re: More earth-shattering VBA code


Thanks for the effort, it is appreciated.

Perhaps a more relevant title that would be more easily found by a google
groups search?


"DFS" <nospam@dfs_.comwrote in message news:IIHfh.71$Iz.38@bigfe9...
Quote:
Just sharing a handy snippet.
>
>
Larry Linson wrote:
Quote:
>Are you just sharing with us, or do you have a question? Generally,
>people don't just post VBA code without some explanation.
>>
> Larry Linson
>>
>"DFS" <nospam@dfs_.comwrote in message
>news:ySrfh.7922$Zz2.2862@bignews3.bellsouth.net.. .
Quote:
>>'Search all reports for a text box named something
>>>
>>Dim cMsg As String, db As Database, rs As Recordset, rpt As Report,
>>ctl as Control
>>Set db = CurrentDb()
>>cMsg = "BuildingID"
>>>
>>Set rs = db.OpenRecordset("SELECT [NAME] AS REPORTOBJ FROM
>>MSYSOBJECTS WHERE [TYPE] = -32764;")
>>Do Until rs.EOF
>>DoCmd.openReport rs("REPORTOBJ"), acViewDesign, , , acHidden
>>Set rpt = Reports(rs("REPORTOBJ"))
>> For Each ctl In rpt.Controls
>> If ctl.ControlType = acTextBox Then
>> If ctl.Name = cMsg Then
>> Debug.Print "Report: " & rpt.Name & " contains " & cMsg
>> Exit For
>> End If
>> End If
>> Next ctl
>>Set rpt = Nothing
>>DoCmd.Close acReport, rs("REPORTOBJ"), acSaveNo
>>rs.MoveNext
>>Loop
>>>
>>rs.Close
>>Set rs = Nothing
>>MsgBox "Finished checking reports for " & cMsg
>
>
>

DFS
Guest
 
Posts: n/a
#5: Dec 13 '06

re: More earth-shattering VBA code


Here ya go...


David F Cox wrote:
Quote:
Thanks for the effort, it is appreciated.
>
Perhaps a more relevant title that would be more easily found by a
google groups search?
>
>
"DFS" <nospam@dfs_.comwrote in message news:IIHfh.71$Iz.38@bigfe9...
Quote:
>Just sharing a handy snippet.
>>
>>
>Larry Linson wrote:
Quote:
>>Are you just sharing with us, or do you have a question? Generally,
>>people don't just post VBA code without some explanation.
>>>
>> Larry Linson
>>>
>>"DFS" <nospam@dfs_.comwrote in message
>>news:ySrfh.7922$Zz2.2862@bignews3.bellsouth.net. ..
>>>'Search all reports for a text box named something
>>>>
>>>Dim cMsg As String, db As Database, rs As Recordset, rpt As Report,
>>>ctl as Control
>>>Set db = CurrentDb()
>>>cMsg = "BuildingID"
>>>>
>>>Set rs = db.OpenRecordset("SELECT [NAME] AS REPORTOBJ FROM
>>>MSYSOBJECTS WHERE [TYPE] = -32764;")
>>>Do Until rs.EOF
>>>DoCmd.openReport rs("REPORTOBJ"), acViewDesign, , , acHidden
>>>Set rpt = Reports(rs("REPORTOBJ"))
>>> For Each ctl In rpt.Controls
>>> If ctl.ControlType = acTextBox Then
>>> If ctl.Name = cMsg Then
>>> Debug.Print "Report: " & rpt.Name & " contains " & cMsg
>>> Exit For
>>> End If
>>> End If
>>> Next ctl
>>>Set rpt = Nothing
>>>DoCmd.Close acReport, rs("REPORTOBJ"), acSaveNo
>>>rs.MoveNext
>>>Loop
>>>>
>>>rs.Close
>>>Set rs = Nothing
>>>MsgBox "Finished checking reports for " & cMsg

Closed Thread