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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

IT-SchubertzCommented:
Hi,

just post your code
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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
edrz01Author Commented:
Andy, looks like a syntax problem with the DoEvents(). It errors saying it is expecting an '='.
IT-SchubertzCommented:
Sorry,
just type DoEvents     and then <ENTER>


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.