Embedded Web Browser login script problem

I have an embedded web browser in a form and it is designed to automatically fill in the username and password and submit. When I step through the code it works great but when I try to run it from either a form load or a click it fails saying incorrect login infortmation. This has me stumped. I have put in delay loops, etc to no avail.

Any ideas?
edrz01Asked:
Who is Participating?
 
IT-SchubertzCommented:
Hi,

any reason why you try to set the user information twice?
try adding Doevents before you set the values and after that:

       DoEvents()
       WebBrowser1.Document.login.focus
       WebBrowser1.Document.login("customer").Value = "USERNAMEGOESHERE"
       WebBrowser1.Document.login("Pswd").Value = "^P@ssW0rd!"
       DoEvents()
       ....
       .Submit


HTH Andy
0
 
IT-SchubertzCommented:
Hi,

just post your code
0
 
edrz01Author Commented:
Option Compare Database

Private Sub Command18_Click()
Me.WebBrowser7.Navigate "http://someserver.com/HPOV_Reports/OVIS_USERNAMEGOESHERE/All/Data.gif"

End Sub

Function Logon()
        SysCmd SYSCMD_SETSTATUS, "Opening Internet Explorer"
        On Error Resume Next
        Set Ie = CreateObject("InternetExplorer.Application")
        If Err.Number <> 0 Then
            MsgBox "Unable to open Internet Explorer" & Chr(13) _
                & "Open it and navigate to Freeclaims.com manually."
            DoCmd.Hourglass False
            SysCmd SYSCMD_CLEARSTATUS
            Exit Function
        End If
        WebBrowser1.Visible = True
        SysCmd SYSCMD_SETSTATUS, "Loading login page"
        With WebBrowser1
            .Navigate "http://someserver.com/hpov_reports/iops.htm"
            .Visible = True
        End With
        For pauseit = 1 To 100
        Next pauseit
        StartTime = Now()
           If DateDiff("s", StartTime, Now) > 120 Then
                WebBrowser1.Visible = False
                MsgBox "Unable to navigate to 'http://someserver.com/hpov_reports/iops.htm" _
                    & Chr(13) & "The site may not be active at this time" _
                    & Chr(13) & "Try to navigate there manually."
                WebBrowser1.Visible = True
                WebBrowser1.Value = Nothing
                'Set WebBrowser1 = Nothing
                DoCmd.Hourglass False
                SysCmd SYSCMD_CLEARSTATUS
                Exit Function
            End If
           Err.Clear
           WebBrowser1.Document.login.focus
       
        WebBrowser1.Document.login("customer").Value = "USERNAMEGOESHERE"
        WebBrowser1.Document.login("Pswd").Value = "^P@ssW0rd!"

WebBrowser1.Document.login.Action = "http://someserver.com/HPOV_IOPS/cgi-bin/RepIOps.exe?content=login&"
        WebBrowser1.Document.login.focus
        WebBrowser1.Document.login("customer").Value = "USERNAMEGOESHERE"
        Password = "^P@ssW0rd!"
        WebBrowser1.Document.login("Pswd").Value = Password
        For pauseit = 1 To 100
        Next pauseit
        WebBrowser1.Document.Forms("LOGIN").submit.focus
        'Ie.Document.LOGIN.submit
 '       MsgBox (Err.Number)
        For pauseit = 1 To 100
        Next pauseit

        If Err.Number = 424 Then
            Err.Clear
        ElseIf Err.Number <> 0 Then
            WebBrowser1.Visible = False
            WebBrowser1.Visible = True
           
            DoCmd.Hourglass False
            SysCmd SYSCMD_CLEARSTATUS
            Exit Function
        End If
        For pauseit = 1 To 100
        Next pauseit

Me.WebBrowser1.Navigate "http://someserver.com/HPOV_IOPS/cgi-bin/RepIOps.exe?utf8=1&content=availability&customer=USERNAMEGOESHERE&startTime=-1&probeType=All+Services&endTime=-1"
End Function

Private Sub Frame0_Click()
Me.WebBrowser1.Visible = True
Logon
Select Case Me.Frame0.Value
Case 1
Me.WebBrowser1.Navigate "http://someserver.com/HPOV_IOPS/cgi-bin/RepIOps.exe?utf8=1&content=availability&customer=USERNAMEGOESHERE&startTime=-1&probeType=All+Services&endTime=-1"
Case 2
Me.WebBrowser1.Navigate "http://someserver.com/HPOV_IOPS/cgi-bin/RepIOps.exe?utf8=1&content=response&customer=USERNAMEGOESHERE&startTime=-1&probeType=All+Services&endTime=-1"
Case 3
Me.WebBrowser1.Navigate "http://someserver.com/HPOV_IOPS/cgi-bin/RepIOps.exe?utf8=1&content=violations&customer=USERNAMEGOESHERE&startTime=-1&probeType=All+Services&endTime=-1"
Case 4
Me.WebBrowser1.Navigate "http://someserver.com/HPOV_IOPS/cgi-bin/RepIOps.exe?utf8=1&content=trend&customer=USERNAMEGOESHERE&metric=AVAILABILITY&probeType=All+Services&serviceGroup=All+Service+Groups"
Case 5
Me.WebBrowser1.Navigate "http://someserver.com/HPOV_IOPS/cgi-bin/RepIOps.exe?utf8=1&content=snapshot&customer=USERNAMEGOESHERE&metric=AVAILABILITY&probeType=All+Services&serviceGroup=All+Service+Groups"
End Select
End Sub
0
 
edrz01Author Commented:
Andy, looks like a syntax problem with the DoEvents(). It errors saying it is expecting an '='.
0
 
IT-SchubertzCommented:
Sorry,
just type DoEvents     and then <ENTER>


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.