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

More earth-shattering VBA code

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

Dec 12 '06 #1
Share this Question
Share on Google+
4 Replies


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

Dec 12 '06 #2

P: n/a
DFS
Just sharing a handy snippet.
Larry Linson wrote:
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:yS*****************@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

Dec 12 '06 #3

P: n/a
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...
Just sharing a handy snippet.
Larry Linson wrote:
>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:yS*****************@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



Dec 13 '06 #4

P: n/a
DFS
Here ya go...
David F Cox wrote:
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...
>Just sharing a handy snippet.
Larry Linson wrote:
>>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:yS*****************@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

Dec 13 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.