wharrison359
asked on
Pop Up Windows in Access Web Object
I am trying to edit .mdb found here http://www.accessmvp.com/djsteele/Access/AA200604.zip for my business needs. I am encountering 2 problems.
1) When I load a webpage that has a pop-up I need that pop-up to stay within the access environment. Whenever I click on the link for the pop-up, the pop-up is in a separate internet explorer window. How do I fix that? Here is a good example you can use to see what I am talking about.
http://www.javascript-coder.com/window-popup/javascript-popup-example4.html
2) When I open the frmWebBrowsing form I always get the message "Your form didn't include an ACTION!" I can't find that message anywhere in the code. I thought it might be a message I was getting from the original website, but even when I changed the website in the Private Sub cmdText_Click(), the message kept appearing. How do I get rid of that message and get my webpage to load when the form is executed?
http://www.javascript-coder.com/window-popup/javascript-popup-example4.html
1) When I load a webpage that has a pop-up I need that pop-up to stay within the access environment. Whenever I click on the link for the pop-up, the pop-up is in a separate internet explorer window. How do I fix that? Here is a good example you can use to see what I am talking about.
http://www.javascript-coder.com/window-popup/javascript-popup-example4.html
2) When I open the frmWebBrowsing form I always get the message "Your form didn't include an ACTION!" I can't find that message anywhere in the code. I thought it might be a message I was getting from the original website, but even when I changed the website in the Private Sub cmdText_Click(), the message kept appearing. How do I get rid of that message and get my webpage to load when the form is executed?
http://www.javascript-coder.com/window-popup/javascript-popup-example4.html
'Here is the code you get in the .mdb found
'at http://www.accessmvp.com/djsteele/Access/AA200604.zip
Option Compare Database
Option Explicit
Dim mlngSelStart As Long
Dim mlngSelLength As Long
Dim mstrSelText As String
Private Sub cmdCopy_Click()
' Clicking on the cmdCopy button is supposed to initiate a copy step
' for whatever was selected on in the txtText text box. Normally, we'd
' use the SelText property of the text box to determine what's been
' selected. However, that property can only be referenced when the text
' box has focus. Since we've clicked on the command button to initiate
' the Copy action, focus isn't on the text box, so we can't use the property.
' That's why we stored the values of the SelText property (plus the
' SelStart and SelLength properties) in module-level variables before
' focus moved away from the text box.
On Error GoTo Err_cmdCopy_Click
Dim intLoop As Integer
Dim intColon As Integer
Dim strEntryType As String
Dim strEntryValue As String
Dim varSelection As Variant
' This message box really isn't necessary. I'm strictly including
' it to demonstrate what the SelStart and SelLength properties
' held.
MsgBox "You've selected " & mlngSelLength & " characters, " & _
"starting at position " & mlngSelStart & vbCrLf & vbCrLf & _
"The selected text is " & mstrSelText
' Initialize the four text boxes to nothing
Me.txtAuthor = vbNullString
Me.txtTitle = vbNullString
Me.txtPublished = vbNullString
Me.txtLCCallNumber = vbNullString
' I'm assuming that the user has selected a complete block of text that
' contains all of the information about the specific book. In other words,
' I'm expecting that mstrSelText contains something like:
' Author: Vogel, Peter, 1953-
' Title: The Visual Basic object and component handbook /
' Peter Vogel.
' Published: Upper Saddle River, NJ : Prentice Hall, 2000.
' LC Call No.: QA76.73.B3V63 2000
'
' Unfortunately, even though that text has labels indicating what each line
' contains, it's still not perfect for our use. The "Title:" line is actually
' split across two lines of text. What we need to do is look at the first 15
' characters of each line, and determine whether it contains a label, or blanks.
' If it contains blanks, assume that it's a continuation of the previous line.
' As well, we're only interested in the four items of information above,
' but it's possible that the entry on the web might have more. For example,
' another one of Peter's book entries is:
' Author: Vogel, Peter, 1953-
' Title: Professional Web parts and custom controls with
' ASP.NET 2.0 / Peter Vogel.
' Published: Indianapolis, IN : Wiley Technology Pub., 2005.
' LC Call No.: TK5105.8885.A26V64 2005
' Access: Table of contents
' Location: http://www.loc.gov/catdir/toc/ecip0516/2005021557.html
'
' What I'm going to do first is split the selected text into individual
' lines, using the Split function with vbCrLf as the delimiter.
' Note that this works because our text is split using the standard Carriage Return/
' Line Feed combination. You need to check the specific web page with which
' you're dealing to make sure this is the case for you.
varSelection = Split(mstrSelText, vbCrLf)
' I need to make sure that strEntryType doesn't contain anything, to make sure
' that nothing gets written to the text boxes when the first line is found
' to have something in the first 15 positions.
strEntryType = vbNullString
' For each line of text, look to see whether there's a colon in the first
' 15 positions. If there is, assume we're starting a new entry.
' If appropriate, write whatever we've currently got in strEntryValue
' to one of the text boxes. Then, store what's in front of the colon as
' strEntryType, and what's after the colon as strEntryValue.
' If there isn't a colon in the first 15 positions, append the contents of
' the line to what's already stored in strEntryValue.
For intLoop = LBound(varSelection) To UBound(varSelection)
intColon = InStr(varSelection(intLoop), ":")
If intColon > 1 And intColon < 16 Then
Select Case strEntryType
Case "Author"
Me.txtAuthor = strEntryValue
Case "Title"
Me.txtTitle = strEntryValue
Case "Published"
Me.txtPublished = strEntryValue
Case "LC Call No."
Me.txtLCCallNumber = strEntryValue
Case Else
' Ignore any other possibilities
End Select
strEntryType = Trim$(Left$(varSelection(intLoop), intColon - 1))
strEntryValue = Trim$(Mid$(varSelection(intLoop), intColon + 1))
Else
strEntryValue = strEntryValue & " " & _
Trim$(varSelection(intLoop))
End If
Next intLoop
' If necessary, write whatever's in strEntryValue to the appropriate
' textbox.
Select Case strEntryType
Case "Author"
Me.txtAuthor = strEntryValue
Case "Title"
Me.txtTitle = strEntryValue
Case "Published"
Me.txtPublished = strEntryValue
Case "LC Call No."
Me.txtLCCallNumber = strEntryValue
Case Else
' Ignore any other possibilities
End Select
Me.pagDetails.SetFocus
End_cmdCopy_Click:
Exit Sub
Err_cmdCopy_Click:
MsgBox "Error " & Err.Number & ": " & Err.Description & vbCrLf & _
" in " & Me.Name & ".cmdCopy_Click", _
vbOKOnly & vbCritical, "Smart Access Answer Column"
Resume End_cmdCopy_Click
End Sub
Private Sub cmdExit_Click()
' We're out of here...
On Error GoTo Err_cmdExit_Click
DoCmd.Close
End_cmdExit_Click:
Exit Sub
Err_cmdExit_Click:
MsgBox "Error " & Err.Number & ": " & Err.Description & vbCrLf & _
" in " & Me.Name & ".cmdExit_Click", _
vbOKOnly & vbCritical, "Smart Access Answer Column"
Resume End_cmdExit_Click
End Sub
Private Sub cmdGo_Click()
' If there's text in txtURL, assume it's a URL, and navigate to it.
On Error GoTo Err_cmdGo_Click
If Len(Me.txtURL) > 0 Then
Me.ocxWebBrowser.Navigate Me.txtURL
End If
End_cmdGo_Click:
Exit Sub
Err_cmdGo_Click:
MsgBox "Error " & Err.Number & ": " & Err.Description & vbCrLf & _
" in " & Me.Name & ".cmdGo_Click", _
vbOKOnly & vbCritical, "Smart Access Answer Column"
Resume End_cmdGo_Click
End Sub
Private Sub cmdGoBack_Click()
' Just to show how you can go back to a previous page in
' the Web Browser control, just as you can with any other browser.
On Error GoTo Err_cmdGoBack_Click
Me.ocxWebBrowser.GoBack
End_cmdGoBack_Click:
Exit Sub
Err_cmdGoBack_Click:
MsgBox "Error " & Err.Number & ": " & Err.Description & vbCrLf & _
" in " & Me.Name & ".cmdGoBack_Click", _
vbOKOnly & vbCritical, "Smart Access Answer Column"
Resume End_cmdGoBack_Click
End Sub
Private Sub cmdGoForward_Click()
' Just to show how you can go forward to a previous page in
' the Web Browser control, just as you can with any other browser.
On Error GoTo Err_cmdGoForward_Click
Me.ocxWebBrowser.GoForward
End_cmdGoForward_Click:
Exit Sub
Err_cmdGoForward_Click:
MsgBox "Error " & Err.Number & ": " & Err.Description & vbCrLf & _
" in " & Me.Name & ".cmdGoForward_Click", _
vbOKOnly & vbCritical, "Smart Access Answer Column"
Resume End_cmdGoForward_Click
End Sub
Private Sub cmdText_Click()
' If there's a web page currently displayed in the Web Browser control,
' display its text content in text box txtText on the second tab.
On Error GoTo Err_cmdText_Click
If Me.ocxWebBrowser.Document Is Nothing Then
MsgBox "No Text to display"
Else
Me.txtText.SetFocus
Me.txtText = Me.ocxWebBrowser.Document.documentElement.innerText
Me.txtText.SelLength = 0
End If
End_cmdText_Click:
Exit Sub
Err_cmdText_Click:
MsgBox "Error " & Err.Number & ": " & Err.Description & vbCrLf & _
" in " & Me.Name & ".cmdText_Click", _
vbOKOnly & vbCritical, "Smart Access Answer Column"
Resume End_cmdText_Click
End Sub
Private Sub Form_Load()
' Preset the URL.
' (Actually, since the rest of the form won't work with any other URL,
' this isn't really necessary. However, it does allow you to prove that
' should you enter another URL, the web browser control will work fine)
On Error GoTo Err_Form_Load
Me.txtURL = "https://vsr.citigroup.net/virtualsecurityrequest"
End_Form_Load:
Exit Sub
Err_Form_Load:
MsgBox "Error " & Err.Number & ": " & Err.Description & vbCrLf & _
" in " & Me.Name & ".Form_Load_Click", _
vbOKOnly & vbCritical, "Smart Access Answer Column"
Resume End_Form_Load
End Sub
Private Sub txtText_LostFocus()
' The SelLength, SelStart and SelText properties can only be referenced
' when the text box has focus. Unfortunately, when we clicking on
' the command button to initiate the Copy action, focus isn't on the
' text box, so we can't use these properties.
' This is the next best thing: setting module-level variables before
' focus moves away from the text box.
On Error GoTo Err_txtText_LostFocus
mlngSelLength = Me.txtText.SelLength
mlngSelStart = Me.txtText.SelStart
mstrSelText = Me.txtText.SelText
End_txtText_LostFocus:
Exit Sub
Err_txtText_LostFocus:
MsgBox "Error " & Err.Number & ": " & Err.Description & vbCrLf & _
" in " & Me.Name & ".txtText_LostFocus_Click", _
vbOKOnly & vbCritical, "Smart Access Answer Column"
Resume End_txtText_LostFocus
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER