Solved

Pop Up Windows in Access Web Object

Posted on 2007-11-16
2
585 Views
Last Modified: 2013-11-29
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
'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

Open in new window

0
Comment
Question by:wharrison359
2 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 20299584

change the codes in your form load event

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"
 
'*** ADD this

    If Len(Me.txtURL) > 0 Then
        Me.ocxWebBrowser.Navigate Me.txtURL
    End If

'****



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
0
 

Author Comment

by:wharrison359
ID: 20300514
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now