If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Set Focus after Navigate
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 |
#2
|
|||
|
|||
"Zadok @ Port of Seattle"
wrote in message news 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. -- Dirk Goldgar, MS Access MVP www.datagnostics.com (please reply to the newsgroup) |
#3
|
|||
|
|||
Dirk,
I have a form PROJECTS, with DRAWINGS Subform containing 'Hyperlink' field which contains the link to the PDF - opening in form VIEWER. Many many thanks! Private Sub View_Click() If Not Nz(Me.Hyperlink, "") = "" Then If Len(Dir([Hyperlink])) 0 Then If CurrentProject.AllForms("VIEWER").IsLoaded Then Forms!VIEWER.Browser.Navigate Me.Hyperlink Forms!VIEWER.Caption = Hyperlink Else DoCmd.OpenForm "VIEWER" Forms!VIEWER.Browser.Navigate Me.Hyperlink Forms!VIEWER.Caption = Hyperlink End If Else 'File Does Not Exist End If End If End Sub |
#4
|
|||
|
|||
"Zadok @ Port of Seattle"
wrote in message Dirk, I have a form PROJECTS, with DRAWINGS Subform containing 'Hyperlink' field which contains the link to the PDF - opening in form VIEWER. Many many thanks! Private Sub View_Click() If Not Nz(Me.Hyperlink, "") = "" Then If Len(Dir([Hyperlink])) 0 Then If CurrentProject.AllForms("VIEWER").IsLoaded Then Forms!VIEWER.Browser.Navigate Me.Hyperlink Forms!VIEWER.Caption = Hyperlink Else DoCmd.OpenForm "VIEWER" Forms!VIEWER.Browser.Navigate Me.Hyperlink Forms!VIEWER.Caption = Hyperlink End If Else 'File Does Not Exist End If End If End Sub It seems you've changed your code from the subform's Current event to the Click event of a button. I take it this button, "View", is on the subform, not on the main form? Do you still want to set the focus to the Sheet_No control after the navigation is complete? If so, did you try this? '----- start of suggested code ----- Private Sub View_Click() Dim strLink As String strLink = Me!Hyperlink & vbNullString If Len(strLink) = 0 Then Exit Sub End If If Len(Dir(strLink)) = 0 Then Exit Sub End If If CurrentProject.AllForms("VIEWER").IsLoaded = False Then DoCmd.OpenForm "VIEWER" End If With Forms!VIEWER .Caption = strLink With !Browser .Navigate strLink Do While .Busy DoEvents Loop End With End With Me.Sheet_No.SetFocus End Sub '----- end of suggested code ----- It occurs to me that you may have to set the focus back to form PROJECTS, too, but I'm not sure of that. Anyway, please post back and tell me if this approach works, or gets you closer. -- Dirk Goldgar, MS Access MVP www.datagnostics.com (please reply to the newsgroup) |
#5
|
|||
|
|||
Looks like you cleaned up my sad code quite nicely. Unfortunately, it seems
to behave the same, focus is still on the VIEWER form. Thanks for all the help Dirk, I'll understand if you are out of solutions. How I tweaked the last section to bring me back to my Form as you suggested. --- With Forms!VIEWER .Caption = strLink With !Browser .Navigate strLink Do While .Busy DoEvents Loop End With End With Forms!PROJECTS.SetFocus Me.Sheet_No.SetFocus End Sub |
#6
|
|||
|
|||
"Zadok @ Port of Seattle"
wrote in message Looks like you cleaned up my sad code quite nicely. Unfortunately, it seems to behave the same, focus is still on the VIEWER form. Thanks for all the help Dirk, I'll understand if you are out of solutions. How I tweaked the last section to bring me back to my Form as you suggested. --- With Forms!VIEWER .Caption = strLink With !Browser .Navigate strLink Do While .Busy DoEvents Loop End With End With Forms!PROJECTS.SetFocus Me.Sheet_No.SetFocus End Sub That's odd. I just tested code almost identical to that, and it worked. Here's the code I tested: '----- start of code ----- Private Sub Command1_Click() Dim strLink As String strLink = "C:\Temp\ACCInvoice110103.pdf" If Len(strLink) = 0 Then Exit Sub End If If CurrentProject.AllForms("frmWebBrowser").IsLoaded = False Then DoCmd.OpenForm "frmWebBrowser" End If With Forms!frmWebBrowser .Caption = strLink With !ActiveXCtl0 .Navigate strLink Do While .Busy DoEvents Loop End With End With Me.SetFocus Me.Sheet_No.SetFocus End Sub '----- end of code ----- Is there other code on either of these forms that might be interfering? You proviously had this code in the form's Current event -- did you remove the code that was there? -- Dirk Goldgar, MS Access MVP www.datagnostics.com (please reply to the newsgroup) |
#7
|
|||
|
|||
I created 2 new forms and pasted your code in with the same results.
Just to clarify: I have a form with a button to open a new form containing a Microsoft WebBrowser element which then displays the PDF and then puts the focus back on the original form and to the control Sheet_No. In your new code, why does Me.SetFocus not set the focus on the VIEWER form? Also Dirk, is 'ActiveXCtl0' the name of your WebBrowser element? |
#8
|
|||
|
|||
"Zadok @ Port of Seattle"
wrote in message I created 2 new forms and pasted your code in with the same results. Odd. I wonder if it has to do with the Access version (I'm using A2002), the OS version (I'm using Windows 2000 Pro), or the version of Acrobat or Acrobat Reader that is serving the web browser control (I'm using a very old version of Acrobat Reader -- 4.0). Just to clarify: I have a form with a button to open a new form containing a Microsoft WebBrowser element which then displays the PDF and then puts the focus back on the original form and to the control Sheet_No. In your new code, why does Me.SetFocus not set the focus on the VIEWER form? Because that code is running on the form that contains the command button, so "Me" refers to that form, not the viewer form. Also Dirk, is 'ActiveXCtl0' the name of your WebBrowser element? Yes. It may be worth finding out if your forms and code work the same on my PC as on yours. If you'd like to send me a cut-down copy of your database, containing only the elements necessary to demonstrate the problem, compacted and then zipped to less than 1MB in size (preferably much smaller) -- I'll have a look at it, time permitting. You can send it to the address derived by removing NO SPAM from the reply address of this message. If that address isn't visible to you, you can get it from my web site, which is listed in my sig. Do *not* post my real address in the newsgroup -- I don't want to be buried in spam and viruses. -- Dirk Goldgar, MS Access MVP www.datagnostics.com (please reply to the newsgroup) |
#9
|
|||
|
|||
"Dirk Goldgar" wrote in message
"Zadok @ Port of Seattle" wrote in message I created 2 new forms and pasted your code in with the same results. Odd. I wonder if it has to do with the Access version (I'm using A2002), the OS version (I'm using Windows 2000 Pro), or the version of Acrobat or Acrobat Reader that is serving the web browser control (I'm using a very old version of Acrobat Reader -- 4.0). Just to clarify: I have a form with a button to open a new form containing a Microsoft WebBrowser element which then displays the PDF and then puts the focus back on the original form and to the control Sheet_No. In your new code, why does Me.SetFocus not set the focus on the VIEWER form? Because that code is running on the form that contains the command button, so "Me" refers to that form, not the viewer form. Also Dirk, is 'ActiveXCtl0' the name of your WebBrowser element? Yes. It may be worth finding out if your forms and code work the same on my PC as on yours. If you'd like to send me a cut-down copy of your database, containing only the elements necessary to demonstrate the problem, compacted and then zipped to less than 1MB in size (preferably much smaller) -- I'll have a look at it, time permitting. Time permitted. Now I've tested the database you sent me, and it works for me. In other words, clicking "View" opens the VIEWER form, displays the "Hyperlink" PDF in the Browser control (I had to change the hyperlink data in the table), and then brings the PROJECTS form to the foreground again with the focus on the subform in the Sheet_No text box. So if that's not what's happening for you, the problem may be in the different versions of the various components that make this work. Did you say what your various software versions are? -- Dirk Goldgar, MS Access MVP www.datagnostics.com (please reply to the newsgroup) |
#10
|
|||
|
|||
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. |
|
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Keeping the focus on the same field as in the previous record | Bill Reed via AccessMonster.com | Using Forms | 5 | June 28th, 2005 06:28 PM |
spinbutton not take focus? | Sandy | Powerpoint | 5 | June 21st, 2005 08:19 AM |
focus stuck in control | Walter | Using Forms | 2 | March 12th, 2005 01:45 PM |
How do I programmatically set focus to the first control in the tab order | [email protected] | General Discussion | 4 | February 24th, 2005 08:18 AM |
Set Focus | Howard | Using Forms | 3 | June 19th, 2004 05:48 PM |