I am trying to open the References form (Tools-References in the VB toolbar) programmatically with no success. Any ideas on how I can do it from a button on a form through a macro or VB code ? I am using Acces 97.
yes, you can create a macro with 2 actions.
Action 1
OpenModule
Module Name
You Need to Provide the Name of an Existing Module
Action 2
SendKeys
KeyStrokes
%(tf)
But if all you want to do is ensure that the references are "refreshed", then you can use this code
First create a query qryTestRefs that uses the Left Function
SELECT Left([companyname],1) AS ComName
FROM Customers;
Then Call the Function CheckRefs()
Function CheckRefs()
Dim db As database, rs As Recordset
Dim X
Set db = CurrentDb
On Error Resume Next
' Run the query qryTestRefs you created and trap for an error.
Set rs = db.OpenRecordset("qryTestRefs", dbOpenDynaset)
' The if statement below checks for error 3075. If it encounters the
' error, it informs the user that it needs to fix the application.
' Error 3075 is the following in Access 97 and Error 3085 in 2K:
' "Function isn't available in expressions in query expression..."
' Note: This function only checks for the error 3075. If you want it to
' check for other errors, you can modify the If statement. To have
' it check for any error, you can change it to the following:
' If Err.Number <> 0
If Err.Number = 3075 Or Err.Number = 3085 Then
MsgBox "This application has detected newer versions " _
& "of required files on your computer. " _
& "It may take several minutes to recompile " _
& "this application."
Err.Clear
FixUpRefs
End If
End Function
Sub FixUpRefs()
Dim r As Reference, r1 As Reference
Dim s As String
' Look for the first reference in the database other
' than Access and Visual Basic for Applications.
For Each r In Application.References
If r.Name <> "Access" And r.Name <> "VBA" Then
Set r1 = r
Exit For
End If
Next
s = r1.FullPath
' Remove the Reference and add it back.
References.Remove r1
References.AddFromFile s
' Call a hidden SysCmd to automatically compile/save all modules.
Call SysCmd(504, 16483)
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.