Very good idea to aid the users with the manuals etc. - Eleftheriadis Constantine web site

This year make the difference ...Make the difference, donate Bon Marrow to help save a lifeΦέτος κάνε την διαφορά ...Κάνε την διαφορά, γίνε δότης μυελού των οστών
me some years before
Go to content

Very good idea to aid the users with the manuals etc.

Tutorials > Vba tools - Code


Here is the procedure that i use for the users to see-read the manuals of each app.
Bellow is the command to open the form (continuous form)
Private Sub cmdTheManuals_Click()
DoCmd.OpenForm "frmScanDirSelectFileFromTable", acNormal, , , acFormPropertySettings, acDialog
End Sub
=========================================================================================
Bellow is the on open event of the form
Private Sub Form_Open(Cancel As Integer)
   On Error GoTo Err_Form_Open
Dim GetFullPath, HelpPath As String
   'The form dimensions
Form.Move Left:=1000, Top:=1000, Width:=8000, Height:=4000
getLogo    ' is a function called to find the app logo etc... (can be omitted or taylormade)
Me.appLogoImg.Picture = appLogo ' the logo img

  Call FilesAndDetails   ' see bellow the sub called


GetFullPath = CurrentProject.FullName ' call the public function to see the path of the app in parameters
'GetPath = CurrentProject.Path '
otherwise can be used this

HelpPath = parmAppPath & "& "Documentation"      ' with new data

Set rst = Nothing
Set rst = CurrentDb.OpenRecordset("SELECT tblFiles.*" _
 & " FROM tblFiles;")

Rem bellow is the code that enables the form footer and form detail if exists data (files found)

If rst.EOF Then
   Forms![frmScanDirSelectFileFromTable].Section(acDetail).Visible = False
   Forms![frmScanDirSelectFileFromTable].Section(acFooter).Visible = True
   Else
   Forms![frmScanDirSelectFileFromTable].Section(acDetail).Visible = True
   Forms![frmScanDirSelectFileFromTable].Section(acFooter).Visible = True
   Set Forms![frmScanDirSelectFileFromTable].Recordset = rst   ' fill the form
   Forms![frmScanDirSelectFileFromTable].countOfFiles = rst.RecordCount ' how many files found
   Forms![frmScanDirSelectFileFromTable].Repaint
End If

   Me.Caption = "Files to be read at : " & DFirst("FilePath", "tblFiles") & " : " & countOfFiles ' caption of the form

Exit_Form_Open:
   Exit Sub
   
Err_Form_Open:
   MsgBox Err.Number & " - " & Err.Description
   Resume Exit_Form_Open

End Sub
==========================================================================
REM Bellow is the code used when click the command to open the selected doc
Private Sub bOpenFile_Click()
On Error GoTo Err_bOpenFile_Click

   OpenFile tbFilePathName   '
public function called bellow

Exit_bOpenFile_Click:
   Exit Sub
   
Err_bOpenFile_Click:
   MsgBox Err.Number & " - " & Err.Description
   Resume Exit_bOpenFile_Click
End Sub
=========================================================================
Public Function OpenFile(sFileName As String)
On Error GoTo Err_OpenFile

   OpenFile = ShellExecute(Application.hWndAccessApp, "Open", sFileName, "", "C:, 1)

Exit_OpenFile:
   Exit Function

Err_OpenFile:
   MsgBox Err.Number & " - " & Err.Description
   Resume Exit_OpenFile

End Function
==========================================================================
REM Function that collects the data from specified dir
Private Function FilesAndDetails()
Dim Test, sPath As String
On Error GoTo Err_FilesAndDetails
GeneralParams
   Dim rs As Recordset
   Dim vDir As Variant

     sPath = parmAppPath & "'sPath must end with a back slash, sPath = "C:
   
   CurrentDb.Execute "Delete tblFiles.* from tblFiles;" '
is the table used to insert the files containing the fields
       ' FilePathName=txt (255) ; FilePath = txt(255)
       ' FileName=txt(100) ; ModifiedDate =Date/time (mm/dd/yyyy hh:nn:ss)
       ' FileSize = dbl(std)
       '
initial cleaned and then refilled
Me.appLogoImg.Picture = appLogo ' the logo img
  Call FilesAndDetails   ' see bellow the sub called

GetFullPath = CurrentProject.FullName ' call the public function to see the path of the app in parameters
'GetPath = CurrentProject.Path ' otherwise can be used this

HelpPath = parmAppPath & "& "Documentation"      ' with new data
Set rst = Nothing
Set rst = CurrentDb.OpenRecordset("SELECT tblFiles.*" _
 & " FROM tblFiles;")
Rem bellow is the code that enables the form footer and form detail if exists data (files found)
If rst.EOF Then
   Forms![frmScanDirSelectFileFromTable].Section(acDetail).Visible = False
   Forms![frmScanDirSelectFileFromTable].Section(acFooter).Visible = True
   Else
   Forms![frmScanDirSelectFileFromTable].Section(acDetail).Visible = True
   Forms![frmScanDirSelectFileFromTable].Section(acFooter).Visible = True
   Set Forms![frmScanDirSelectFileFromTable].Recordset = rst   ' fill the form
   Forms![frmScanDirSelectFileFromTable].countOfFiles = rst.RecordCount ' how many files found
   Forms![frmScanDirSelectFileFromTable].Repaint
End If
   Me.Caption = "Files to be read at : " & DFirst("FilePath", "tblFiles") & " : " & countOfFiles ' caption of the form
Exit_Form_Open:
   Exit Sub
   
Err_Form_Open:
   MsgBox Err.Number & " - " & Err.Description
   Resume Exit_Form_Open
End Sub
==========================================================================
REM Bellow is the code used when click the command to open the selected doc
Private Sub bOpenFile_Click()
On Error GoTo Err_bOpenFile_Click
   OpenFile tbFilePathName   ' public function called bellow
Exit_bOpenFile_Click:
   Exit Sub
   
Err_bOpenFile_Click:
   MsgBox Err.Number & " - " & Err.Description
   Resume Exit_bOpenFile_Click
End Sub
=========================================================================
Public Function OpenFile(sFileName As String)
On Error GoTo Err_OpenFile
   OpenFile = ShellExecute(Application.hWndAccessApp, "Open", sFileName, "", "C:, 1)
Exit_OpenFile:
   Exit Function
Err_OpenFile:
   MsgBox Err.Number & " - " & Err.Description
   Resume Exit_OpenFile
End Function
==========================================================================
REM Function that collects the data from specified dir
Private Function FilesAndDetails()
Dim Test, sPath As String
On Error GoTo Err_FilesAndDetails
GeneralParams
   Dim rs As Recordset
   Dim vDir As Variant
     sPath = parmAppPath & "'sPath must end with a back slash, sPath = "C:
   
   CurrentDb.Execute "Delete tblFiles.* from tblFiles;" ' is the table used to insert the files containing the fields
       ' FilePathName=txt (255) ; FilePath = txt(255)
       ' FileName=txt(100) ; ModifiedDate =Date/time (mm/dd/yyyy hh:nn:ss)
       ' FileSize = dbl(std)
       ' initial cleaned and then refilled
   Set rs = CurrentDb.OpenRecordset("tblFiles")
   
   vDir = Dir(sPath & "*.*")
   Do Until vDir = ""
       rs.AddNew
       rs!FilePathName = sPath & vDir
       rs!FilePath = sPath
       rs!FileName = vDir
       rs!ModifiedDate = FileDateTime(sPath & vDir)
       rs!FileSize = FileLen(sPath & vDir)
       rs.Update
       vDir = Dir
   Loop
   
   rs.Close
   Set rs = Nothing
Exit_FilesAndDetails:
   Exit Function
   
Err_FilesAndDetails:
   MsgBox Err.Number & " - " & Err.Description
   Resume Exit_FilesAndDetails
End Function
=========================================================================
REM public functions
Rem is the function called to open the file with the appropriate prg
Public Function OpenFile(sFileName As String)
On Error GoTo Err_OpenFile
   OpenFile = ShellExecute(Application.hWndAccessApp, "Open", sFileName, "", "C:, 1)
Exit_OpenFile:
   Exit Function
Err_OpenFile:
   MsgBox Err.Number & " - " & Err.Description
   Resume Exit_OpenFile
End Function

Hit to see the demo
12/5/2023
Back to content