By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,870 Members | 2,457 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,870 IT Pros & Developers. It's quick & easy.

Data field loses focus using AcroPDF in Access 2003

P: 1
Hello,

I use the following VBA code to pick up PDF's from a folder and show it in an Access form.

code:
--------
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Public strImageFile As String
  3.  
  4. Private Function GetImageFolder() As String
  5. Dim DBFullPath As String
  6. Dim I As Integer
  7.  
  8. DBFullPath = CurrentDb().Name
  9.  
  10. ' Strip the filename from the full path
  11. For I = 1 To Len(DBFullPath)
  12. If Mid(DBFullPath, I, 1) = "\" Then
  13. GetImageFolder = Left(DBFullPath, I) & "Images\SIDA0001\" 'Name and relative place of subfolder where I keep pdf's
  14. End If
  15. Next
  16.  
  17. End Function
  18.  
  19.  
  20. Private Sub Form_Current()
  21. ' retrieve the path where images are stored - in this case the it's the path of the .mdb file itself
  22. Dim Path As String
  23. Path = GetImageFolder
  24.  
  25. 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.
  26.  
  27. AcroPDF1.LoadFile (Path & Me!EnkätID & ".pdf")
  28. AcroPDF1.setView ("Fit")
  29. AcroPDF1.setShowScrollbars (False)
  30.  
  31.  
  32. Else
  33.  
  34. AcroPDF1.LoadFile (Path & Me!EnkätID & ".pdf")
  35. AcroPDF1.setView ("Fit")
  36. AcroPDF1.setShowScrollbars (False)
  37.  
  38.  
  39.  
  40.  
  41. End If
  42.  
  43. 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.
May 31 '08 #1
Share this Question
Share on Google+
1 Reply


NeoPa
Expert Mod 15k+
P: 31,489
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) :
Expand|Select|Wrap|Line Numbers
  1. 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.
Jun 2 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.