Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Good way to locate occurrence of table and queries, Form use

Status
Not open for further replies.

jase2006

Technical User
Nov 17, 2006
53
0
0
GB
Hi, I would like to locate the occurrence a certain table and query in all Forms. Is there a faster way than going into Form design mode and check the properties to see what table or query is used?
 
Use code.

Code:
For Each frm In CurrentProject.AllForms
    DoCmd.OpenForm frm.Name, acDesign
    Debug.Print Forms(frm.Name).RecordSource
    DoCmd.Close acForm, frm.Name, acSaveNo
Next
 
Can you please tell me what frm is declare and set as?
Thanks
 
There is no need to set. You can:

Dim frm As Object
 
Right I declare frm AS Object. But is "CurrentProject" available in ACCESS 97? It doesn't seem to recognise it?
 
Access 97 is quite different from the more recent releases. It is best that you mention the version in all your posts. I cannot test this, but it may suit:

Code:
Dim rs As Recordset

strSQL = "SELECT [Name] FROM MsysObjects " _
& "WHERE [Type] = -32768"

Set rs = CurrentDb.OpenRecordset(strSQL)

Do Until rs.EOF
    Debug.Print rs!Name

    DoCmd.OpenForm rs!Name, acDesign
    Debug.Print Forms(rs!Name).RecordSource
    DoCmd.Close acForm, rs!Name, acSaveNo
    
    rs.MoveNext
Loop
 
That is perfert, just need to little tweaking.

Thanks again
 
but be aware that other constructs may reference the table/query. ComboBoxes and ListBoxes have a "RowSource" property which may be set to a table/query and Domain aggregate function (DSum, DMin, DMax, ... ) may be used as the control source ...

Other examples abound, so these are just the most common.

If your quest is to determine if the object (table / query) is used anywhere, the quest is a LOT more complicated than just the form recordsource!




MichaelRed


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top