Hello,
I use the following VBA code to pick up PDF's from a folder and show it in an Access form.
code:
--------
-------------
This works fine! However when trying to scroll through these PDF's in the form it will lose focus from the EnkätID field in the form so that I can't scroll. I need point my mouse to the data field and select it again in order to scroll 1 more PDF.
I want to regain focus automatically to the EnkätID data field on the form.
How to do this?
Thanks!
Best,
Niclas.
I use the following VBA code to pick up PDF's from a folder and show it in an Access form.
code:
--------
Code:
Option Compare Database
Public strImageFile As String
Private Function GetImageFolder() As String
Dim DBFullPath As String
Dim I As Integer
DBFullPath = CurrentDb().Name
' Strip the filename from the full path
For I = 1 To Len(DBFullPath)
If Mid(DBFullPath, I, 1) = "\" Then
GetImageFolder = Left(DBFullPath, I) & "Images\SIDA0001\" 'Name and relative place of subfolder where I keep pdf's
End If
Next
End Function
Private Sub Form_Current()
' retrieve the path where images are stored - in this case the it's the path of the .mdb file itself
Dim Path As String
Path = GetImageFolder
If IsEmpty(Me!EnkätID) Or IsNull(Me!EnkätID) Then 'Picking up the name for the PDF-file from an ID field in access table.
AcroPDF1.LoadFile (Path & Me!EnkätID & ".pdf")
AcroPDF1.setView ("Fit")
AcroPDF1.setShowScrollbars (False)
Else
AcroPDF1.LoadFile (Path & Me!EnkätID & ".pdf")
AcroPDF1.setView ("Fit")
AcroPDF1.setShowScrollbars (False)
End If
End Sub
This works fine! However when trying to scroll through these PDF's in the form it will lose focus from the EnkätID field in the form so that I can't scroll. I need point my mouse to the data field and select it again in order to scroll 1 more PDF.
I want to regain focus automatically to the EnkätID data field on the form.
How to do this?
Thanks!
Best,
Niclas.
Comment