ACC97: Invalid File Name Causes Untrappable Error in Assistant (161030)
The information in this article applies to:
This article was previously published under Q161030 Advanced: Requires expert coding, interoperability, and multiuser skills.
SYMPTOMS
If you set an invalid FileName property for the Assistant object in Visual
Basic for Applications code, a trappable run-time error does not occur
until you click Cancel in the message box that appears.
RESOLUTION
You can use the FileSearch object to determine if the Assistant file
exists before you set the FileName property in code. The following sample
code uses the FileSearch object to search for the Assistant file before
you set the FileName property:
- Open the sample database Northwind.mdb.
- Create a module and type the following procedure:
Sub SetAssistant(ActFile as String)
On Error GoTo SetAssistant_Err
Dim fs As FileSearch
Dim accObj as Object
Dim i As Integer
' Search for the Assistant file name.
Set fs = Application.FileSearch
With fs
.LookIn = "C:\"
.SearchSubFolders = True
.FileName = ActFile
If .Execute > 0 Then
Set accObj = CreateObject("Access.Application")
With accObj
.Visible = True
.Assistant.FileName = ActFile
.Assistant.Visible = True
End With
Else
MsgBox "The Assistant file you specified was not found."
End If
End With
GoTo SetAssistant_Exit
SetAssistant_Exit:
Set fs = Nothing
Set accObj = Nothing
Exit Sub
SetAssistant_Err:
MsgBox Err.Number
Resume SetAssistant_Exit
End Sub
- With the module still open in Design view, click References on the Tools menu.
- In the References dialog box, click Microsoft Office 8.0 Object Library in the Available References box. If that reference does not appear,
click the Browse button and browse your hard drive for MSO97.DLL.
- Click OK in the References dialog box.
- To test the procedure, type the following line in the Debug window,
and then press ENTER:
SetAssistant("clippit.act")
If Clippit.act exists on your computer, an instance of Microsoft Access
starts, shows the Assistant, and then quits. If the file does not
exist, you receive an error message and the procedure stops.
STATUS
Microsoft has confirmed this to be a problem in Microsoft Access 97.
REFERENCES
For more information about programming with the Office Assistant, search
the Help Index for "Assistant object."
Modification Type: | Minor | Last Reviewed: | 10/11/2006 |
---|
Keywords: | kbbug kberrmsg kbProgramming KB161030 |
---|
|