Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old December 12th, 2006, 05:55 AM
DFS
Guest
 
Posts: n/a
Default 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



  #2  
Old December 12th, 2006, 10:15 PM
Larry Linson
Guest
 
Posts: n/a
Default 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
>
>
>

  #3  
Old December 12th, 2006, 11:55 PM
DFS
Guest
 
Posts: n/a
Default 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

  #4  
Old December 13th, 2006, 10:35 AM
David F Cox
Guest
 
Posts: n/a
Default 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
>
>
>

  #5  
Old December 13th, 2006, 12:45 PM
DFS
Guest
 
Posts: n/a
Default 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

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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.
Post your question now . . .
It's fast and it's free

Popular Articles