
December 12th, 2006, 05:55 AM
| | | More earth-shattering VBA code
'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 | 
December 12th, 2006, 10:15 PM
| | | 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
>
>
>
| | 
December 12th, 2006, 11:55 PM
| | | 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
| | | 
December 13th, 2006, 10:35 AM
| | | 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
| | >
>
>
| | 
December 13th, 2006, 12:45 PM
| | | Re: search all reports for a control named 'X' (was: 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
| | | |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over network members.
|