Question : How to open multiple pdf files in datasheet view

Hi,

I have an MS Access 2003 database. There is a command button "open By Site Name" which asks user to enter a "site name" which is a field. By entering the site name the respective names are displayed in datasheet view. I want to have another feature by which all the pdf files stored in a folder which are related to each site name (displayed in datasheet) by its name are opened. Below is my code. right now it just shows type mismatch error when the button is clicked and the datasheet is opened.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
Private Sub Command101_Click()
 
On Error GoTo Err_Command101_Click
 
    Dim stDocName As String
  Dim sFile As String
    Dim sDir As String
    Dim Path        As String
    Dim sSite As String
    Dim fso As New Scripting.FileSystemObject
    Dim fls As Folders, fl As Folder
    stDocName = "open By Site Name"
    DoCmd.RunMacro stDocName
 
 
  If stDocName = True Then
    Set fls = fso.GetFolder("D:\SAP - Private Sites LA\").SubFolders
 
    sSite = "D:\SAP - Private Sites LA\"
    sDir = ""
    
    sFile = Me.Site_Name & ".pdf"
    sPath = sSite & sDir & sFile
 
    If Dir$(sPath) <> "" Then
                    FollowHyperlink sPath
    Else
                    MsgBox "Cannot locate file " & sPath
    End If
 
   
    For Each fl In fls
        sPath = fl.Path & "\" & sFile
        If Dir$(sPath) <> "" Then
        FollowHyperlink sPath
        Else
                        'MsgBox "Cannot locate file " & sPath
        End If
        
    Next
End If
Exit_Command101_Click:
    Exit Sub
 
Err_Command101_Click:
    MsgBox Err.Description
    Resume Exit_Command101_Click
 
 
End Sub

Answer : How to open multiple pdf files in datasheet view

Oh, my appologies sahi,

I have linked the Form 'By Site Name' to the query 'By Site Name' when in fact it should be 'By Site Name_PB'.

If you open the Form 'By Site Name' in design  mode. Go to 'View=>Properties' and change the Record Source from 'By Site Name' to 'By Site Name_PB', that should fix your problem.
Random Solutions  
 
programming4us programming4us