Data field loses focus using AcroPDF in Access 2003

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bracciano
    New Member
    • May 2008
    • 1

    #1

    Data field loses focus using AcroPDF in Access 2003

    Hello,

    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.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    Niclas, Please try to explain the question in words rather than expect anyone to read and decipher your code. Code is fine for extra reference, and is often necessary. It should not be in place of the question however.

    If you want a particular form control to have the focus, then the command would be (in this case) :
    Code:
    Call Me.EnkätID.SetFocus
    Exactly where you'd put it depends on where it is losing the focus which is not clear from your question.

    Let us know if this fixes your problem.

    Comment

    Working...