Set Focus after Navigate

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form (VIEWER) with a Web Browser window that shows me a pdf file
when I either click a button or hit <enter> to go to the next pdf record.
Once a pdf loads in the browser, I cannot for the life of me get the focus
back onto my form. I've done this code which flashes the control focus where
I want it (Sheet_No), but then the pdf loads and takes focus with it.

Private Sub Form_Current()
Forms!VIEWER.Browser.Navigate Me.Hyperlink
Sheet_No.SetFocus
End Sub

Thanks!
Zadok
 
"Zadok @ Port of Seattle"
I have a form (VIEWER) with a Web Browser window that shows me a pdf
file when I either click a button or hit <enter> to go to the next
pdf record. Once a pdf loads in the browser, I cannot for the life of
me get the focus back onto my form. I've done this code which flashes
the control focus where I want it (Sheet_No), but then the pdf loads
and takes focus with it.

Private Sub Form_Current()
Forms!VIEWER.Browser.Navigate Me.Hyperlink
Sheet_No.SetFocus
End Sub

Thanks!
Zadok

Try waiting in a DoEvents loop while the browser control is busy:

With Forms!VIEWER.Browser
.Navigate Me.Hyperlink
Do While .Busy
DoEvents
Loop
End With

Me.Sheet_No.SetFocus
 
Dirk,
I put this in my 'click' event on my form to navigate the subform (VIEWER),
and it acts the same. Am I missing something.

Thanks for the help.
Zadok
 
"Zadok @ Port of Seattle"
Dirk,
I put this in my 'click' event on my form to navigate the subform
(VIEWER), and it acts the same. Am I missing something.

What is your exact code now? And what exactly is the
form/subform/control structure? You didn't say anything about a subform
before.
 
well that is good news for you and bad for me, eh. thanks again for the
trouble shooting Dirk. guess i'm out of luck. i'm using XP, Access 2003,
Acrobat Pro 6.0.
 
"Zadok @ Port of Seattle"
well that is good news for you and bad for me, eh. thanks again for
the trouble shooting Dirk. guess i'm out of luck. i'm using XP,
Access 2003, Acrobat Pro 6.0.

Not necessarily. I'll bet you I can figure out a way to make it work
for you. Give me a day or so to tinker with it.

Do you really need to open your drawings in the web browser control?
Would it work to just open them in Acrobat, in an external window?
 
i had it opening in an external window, the problem was that i couldnt see
both my database and the pdf. i need to see the pdf to type in the
information on the blueprint for the database.
 
Dirk, I've also noticed that if I ever switch to view the VIEWER form and
come back to the PROJECTS form, focus is lost, even outside of running the
code. It looks like the VIEWER/WEB BROWSER element just always grabs focus no
matter what.
 
"Zadok @ Port of Seattle"
Dirk, I've also noticed that if I ever switch to view the VIEWER form
and come back to the PROJECTS form, focus is lost, even outside of
running the code. It looks like the VIEWER/WEB BROWSER element just
always grabs focus no matter what.

I don't kinow what's going on there or why. But let's see if I can get
you closer to where you want to go. In the Declarations section of the
code module of the PROJECTS form, put this function declaration:

Private Declare Function Putfocus Lib "user32" _
Alias "SetFocus" (ByVal hwnd As Long) _
As Long

Then, in the code for the command button, after the lines

Me.SetFocus
Me.Sheet_No.SetFocus

add the following line:

Putfocus Me.hWnd

I can't make a meaningful test of this here, since the original code
works for me. But let me know if that makes a difference for you.
 
Back
Top