Solved

why my code login on a web site with access vba don't work on microsoft access 2016

Posted on 2016-10-31
26
44 Views
Last Modified: 2016-11-10
hi

this is my code:
Private Sub Command0_Click()
   With CreateObject("InternetExplorer.Application")
     .Navigate "http://www.login.com/Ext_Login.aspx"
     Do Until .ReadyState = 4
       DoEvents
     Loop
     DoEvents
     With .Document
        Document.items("frmLogin$UserName") = "username"
        .items("frmLogin$Password") = "12345"
        .items("frmLogin$LoginButton").submit
     End With
  End With
End Sub

Open in new window


but when i try to use this code i get an error message run time error 424 object required and i when i click on debug i see a error message on this line
 Document.items("frmLogin$UserName") = "username"

Open in new window

.

on the references microsoft internet controls is selected.

thanks a lot
0
Comment
Question by:bill201
26 Comments
 
LVL 6

Expert Comment

by:Michael
ID: 41868038
Does this help?
Private Sub Command0_Click()
   Set objIE = CreateObject("InternetExplorer.Application")
   With objIE
     .Navigate "http://www.login.com/Ext_Login.aspx"
     Do Until .ReadyState = 4
       DoEvents
     Loop
     DoEvents
     With .Document
        .items("frmLogin$UserName") = "username"
        .items("frmLogin$Password") = "12345"
        .items("frmLogin$LoginButton").submit
     End With
  End With
End Sub

Open in new window

0
 

Author Comment

by:bill201
ID: 41868039
thanks a lot but the code still don't works. this is how the code is written now
    Set Document = CreateObject("internetexplorer.application")
    With Document
    .Navigate "http://www.login.com/Ext_Login.aspx"
    Do Until .ReadyState = 4
       DoEvents
     Loop
     DoEvents
        .items("frmLogin$UserName") = "username"
        .items("frmLogin$Password") = "12345"
        .items("frmLogin$LoginButton").submit
  End With

Open in new window


and this is the error message that i get
run time error 438
object dosn't support this property or method.
0
 

Author Comment

by:bill201
ID: 41868088
thanks a lot but also the new code don't work and i got the same error message, is there a possibility to make visible the vba internet explorer browser, then i will maybe be able to see what is going on?
0
 
LVL 33

Expert Comment

by:Norie
ID: 41868097
Try this.
Private Sub Command0_Click()
Dim objIE As Object
Dim doc As Object 

   Set objIE = CreateObject("InternetExplorer.Application")

   With objIE
     .Navigate "http://www.login.com/Ext_Login.aspx"
     Do Until .ReadyState = 4
       DoEvents
     Loop
     .Visible = True

     Set doc = .document
   End With
   
     With doc
        .items("frmLogin$UserName") = "username"
        .items("frmLogin$Password") = "12345"
        .items("frmLogin$LoginButton").submit
     End With

End Sub

Open in new window

0
 
LVL 84
ID: 41868109
Are you absolutely sure the web document is the same (i.e. that "frmLogin$UserName" exists)?
0
 

Author Comment

by:bill201
ID: 41868113
thanks a lot now it's open the page but still it's dosn't fill the name and password, i will give you the html source code and please check me whats wrong with my field name.

this is the code
                <table cellspacing="0" cellpadding="4" id="frmLogin" style="background-color:#F7F6F3;border-color:#E6E2D8;border-width:1px;border-style:Solid;border-collapse:collapse;right: 230px; position: absolute; top: 450px; width: 320px; height:170px">
	<tr>
		<td><table cellpadding="0" style="color:#333333;font-family:Arial;font-size:Medium;height:120px;">
			<tr>
				<td align="center" colspan="2" style="color:White;background-color:#5D7B9D;font-size:14pt;font-weight:bold;">הכנסת פרטים מזהים</td>
			</tr><tr>
				<td align="right" style="font-size:Medium;"><label for="frmLogin_UserName">שם משתמש</label></td><td><input name="frmLogin$UserName" type="text" id="frmLogin_UserName" style="font-size:Medium;height:25px;width:200px;" /><span id="frmLogin_UserNameRequired" title="User Name is required." style="visibility:hidden;">*</span></td>
			</tr><tr>
				<td align="right" style="font-size:Medium;"><label for="frmLogin_Password">סיסמא</label></td><td><input name="frmLogin$Password" type="password" id="frmLogin_Password" style="font-size:Medium;height:25px;width:200px;" /><span id="frmLogin_PasswordRequired" title="Password is required." style="visibility:hidden;">*</span></td>
			</tr><tr>
				<td align="right" colspan="2"><input type="submit" name="frmLogin$LoginButton" value="אישור" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;frmLogin$LoginButton&quot;, &quot;&quot;, true, &quot;frmLogin&quot;, &quot;&quot;, false, false))" id="frmLogin_LoginButton" style="color:#284775;background-color:#FFFBFF;border-color:#CCCCCC;border-width:1px;border-style:Solid;font-family:Arial;font-size:Medium;height:25px;" /></td>
			</tr>
		</table></td>
	</tr>
</table>
    </strong>    


    <table   style="right: 230px; position: absolute; top: 630px; font-size: small; font-weight: 700;">
          <tr>
      <td>
          <a href="#" onclick="showItems('lblenterusername','txtpassRecover1','btnrecPass',this);">
      <span id="label1" style="font-family:Arial;font-size: x-small">שכחת את סיסמתך?</span></a>
    </td>  </tr>
       
        <tr><td>
     <span id="lblenterusername" style="font-family:Arial;font-size: x-small;display: none;">אנא הכנס שם משתמש על מנת לקבל את סיסמתך:</span>
            </td>
            </tr>
         <tr><td>
    <input name="txtpassRecover1" type="text" id="txtpassRecover1" style="width:120px;display: none;" />   </td>
            </tr>
          <tr><td>
        <input type="submit" name="btnrecPass" value="שלח" id="btnrecPass" style="height:25px;display: none;" />  </td>
            </tr>
           
               </table>

                <!-- sub Box ------->
                
                
<script type="text/javascript">
//<![CDATA[
var Page_Validators =  new Array(document.getElementById("frmLogin_UserNameRequired"), document.getElementById("frmLogin_PasswordRequired"));
//]]>
</script>

<script type="text/javascript">
//<![CDATA[
var frmLogin_UserNameRequired = document.all ? document.all["frmLogin_UserNameRequired"] : document.getElementById("frmLogin_UserNameRequired");
frmLogin_UserNameRequired.controltovalidate = "frmLogin_UserName";
frmLogin_UserNameRequired.errormessage = "User Name is required.";
frmLogin_UserNameRequired.validationGroup = "frmLogin";
frmLogin_UserNameRequired.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
frmLogin_UserNameRequired.initialvalue = "";
var frmLogin_PasswordRequired = document.all ? document.all["frmLogin_PasswordRequired"] : document.getElementById("frmLogin_PasswordRequired");
frmLogin_PasswordRequired.controltovalidate = "frmLogin_Password";
frmLogin_PasswordRequired.errormessage = "Password is required.";
frmLogin_PasswordRequired.validationGroup = "frmLogin";
frmLogin_PasswordRequired.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
frmLogin_PasswordRequired.initialvalue = "";
//]]>
</script>

Open in new window


this is the web page http://www.enativ.com/Ext_Login.aspx
(the labels are in hebrew so i hope you will understand the code).

thanks a lot
0
 

Author Comment

by:bill201
ID: 41868117
what i understand it's a form on the web page http://www.enativ.com/Ext_Login.aspx, the form name is form1 and the login username field name on the form is frmLogin_UserName, so how i has to write the address on vba ?
0
 
LVL 33

Expert Comment

by:Norie
ID: 41868122
This appears to work.
Private Sub Command0_Click()
Dim objIE As Object
Dim doc As Object
Dim frm As Object

    Set objIE = CreateObject("InternetExplorer.Application")

    With objIE
        .Navigate "http://www.enativ.com/Ext_Login.aspx"
        Do Until .ReadyState = 4
            DoEvents
        Loop
        .Visible = True

        Set doc = .document
    End With

    Set frm = doc.forms(0)

    frm("frmLogin_UserName").Value = "username"
    frm("frmLogin_Password").Value = "12345"
    frm.submit

End Sub

Open in new window

0
 

Author Comment

by:bill201
ID: 41868138
thanks a lot the username has been filled out, but not the password, why is that? (maybe it's possible to solving the problem with  the  tab key, to send a tab button after filling out the username field, how can i send a tab key?)
0
 
LVL 33

Expert Comment

by:Norie
ID: 41868146
When I run the code there's definitely something going in the password box - I can actually 'see' it happening when I step through.

Of course when the form is submitted there's a 'Login Failed' message but that's expected since the code doesn't use a valid username/password combination.
0
 

Author Comment

by:bill201
ID: 41881642
Thanks for your excellent answer but I need a solution how to fill the password. I need it for my employees that are not familior with internet, so I prefer to make thanks easy for them, so they will not have to press any password, every think will be make auto by programming.
0
 
LVL 33

Expert Comment

by:Norie
ID: 41881704
As I said, when I run the code I posted the password is filled in.

Did you change what I posted in any way?
0
 

Author Comment

by:bill201
ID: 41881778
no, i don't change nothing it's just don't fill the form, what browser do you use?
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:bill201
ID: 41881782
now i test it in another way to put the password and then the name but after it's fill the name it's been deleted the password for some reason
0
 
LVL 33

Expert Comment

by:Norie
ID: 41881807
The code uses whichever version of Internet Explorer you have installed.

It doesn't work with any other browser.

Are you entering a valid username and password in the code?
0
 

Author Comment

by:bill201
ID: 41881851
yes its a valid login, and when i fill the details manually, i log in
0
 

Author Comment

by:bill201
ID: 41881901
i'm able to login manually with the same version that the vba don't work, it's internet explorer 11, how can i try to login with another browser like chrome for example ?
0
 
LVL 33

Expert Comment

by:Norie
ID: 41881907
If you comment out this line, run the code and goto Internet Explorer has something been entered in the password field?
   frm.submit

Open in new window

0
 

Author Comment

by:bill201
ID: 41881910
yes the password is filled out and i'm able to login.
0
 
LVL 33

Expert Comment

by:Norie
ID: 41881913
So the code is filling in the password and the problem appears to be when actually submitting the form?

When you run the code without that line commented out do you get any messages on the webpage?

For example, incorrect username/password?
0
 

Author Comment

by:bill201
ID: 41881966
No I don't get  any message before I click On the login button.
0
 
LVL 33

Expert Comment

by:Norie
ID: 41882030
I mean when you run the code through, including this line.
frm.submit

Open in new window

When I do that I get a message asking if I've forgotten the password.

Also, when that happens the password field is cleared so it appears as though a password was never entered.
0
 

Author Comment

by:bill201
ID: 41882036
because i don't  attached here the correct login information  (i can send it to you privately the login details
0
 
LVL 33

Accepted Solution

by:
Norie earned 500 total points
ID: 41882056
The code I posted does enter the username and password from the code into the appropriate fields on the webpage.

You can check that if you step through the code line by line using F8, checking the webpage as you go.
0
 

Author Comment

by:bill201
ID: 41882273
now its working thanks a million
0
 

Author Closing Comment

by:bill201
ID: 41882283
full and exact answer, thank you and thanks for every one that tried to help
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

11 Experts available now in Live!

Get 1:1 Help Now