Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Popup as active window

Status
Not open for further replies.

childrenfirst

Technical User
Oct 15, 2006
80
US
Hi,

I am not sure if it can be done... Hopefully I can get some help from you all:)

I have an Access form that populates hyperlinks. When users click on a hyperlink, a .htm document will open in a new popup window. The problem is that the Access form window still stays active after the popup window is loaded and the user has to click on the popup window in order to view the .htm document. Is there anyway to set the popup window as the active window so that users can click on the hyperlink in the form window, new popup window loads and the user can view the .htm document without doing more?

Thank you!
 
How are ya childrenfirst . . .

In VBE help have a look at the [blue]AppActivate[/blue] statement! . . .

Calvin.gif
See Ya! . . . . . .
 
try the setfocus or docmd.close "form_name" after opening the link
 
Hi,

I modified my code with the AppActivate statement(I could not use the setfocus because there was no control to focus on on the opened .htm document). The .htm document now becomes the active window (the AppActivate statement helped!) after users click on the hyperlink in the Access form. However, when user tried to go back to the Access form, he/she would get an error message "Run-Time Error '5': Invalid procedure call or argument". Please help!

Private Sub txtDocumentLink_Click()

'On Error GoTo Err_txtDocumentLink_Click

Const LANPATH = "\\networkfolder\Download\"
Dim MyIE As Object
Dim strURL As String


strURL = LANPATH & txtDocumentLink.Value

'Set up an invisible control e.g. "cmdDummy" & exploit its Hyperlink methods
Me.CmdDummy.HyperlinkAddress = strURL
CmdDummy.Hyperlink.Follow


AppActivate "strULR"
DoCmd.Maximize

'Exit_txtDocumentLink_Click:
Exit Sub

'Err_txtDocumentLink_Click:
MsgBox Err.Description
Resume Exit_txtDocumentLink_Click

End Sub
 
I wonder why you use an hidden control instead of simply this:
Application.FollowHyperlink strURL

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I was unable to open the hyperlink. Someone advised me to use a dummy command button, and it worked...

I just replaced the dummy command with your suggestion. The .htm document opened in the active window, but I still got the same run-time error message.

Please advise! Thank you:)
 
Which line of code highlighted when in debug mode ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The line of code, AppActivate "strULR", is highlighted when debugging.
 
And this ?
AppActivate strURL

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PH,

I removed the double quotes around strULR and changed the typo from strULR to strURL, but still got the same error message.

After the document is open in the active window and user clicks on the Access form, there is a 20-second pause before the error message pops up. I am not sure if this little clue helps...

Is it possible that the error occured because the line of code, AppActivate strURL, forces the Access form to stay inactive? If yes, how do we disable the code after the document is open in an active window?

Thank you for your help!

 
What about simply this ?
Private Sub txtDocumentLink_Click()
Const LANPATH = "\\networkfolder\Download\"
Dim strURL As String
strURL = LANPATH & txtDocumentLink.Value
Application.FollowHyperlink strURL
DoEvents
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PV,

I replaced my code with yours. I did not get an error message but the focus is back on the Access form immediately after the document opens. I need the focus to stay on the open document's window until users choose to go back to the Access form.

If I tried to add AppActivate strURL back to the end of your code (after DoEvents), I got the error message again.

Thank you!!
 
And this (some side effect I guess ...)
Private Sub txtDocumentLink_Click()
Const LANPATH = "\\networkfolder\Download\"
Dim strURL As String
strURL = LANPATH & txtDocumentLink.Value
Application.FollowHyperlink strURL
DoEvents
[!]DoCmd.RunCommand acCmdAppMinimize[/!]
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PH,

I tried the minimize command before and it only minimized the form without activating the open document's window. The focus still stays on the application, Access, instead of the open document in IE.

Thank you for the idea:)
 
it only minimized the form
I don't suggested DoCmd.Minimize !
Please reread carefully the red part of my previous post.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PH,

Yes, I used your code, DoCmd.RunCommand acCmdAppMinimize, but it only minimized the form, not the application. So, the document window remains inactive...

Thank you for your help though! Have a good night!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top