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

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
bill201Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
NorieConnect With a Mentor VBA ExpertCommented:
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
 
MichaelBusiness AnalystCommented:
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
 
bill201Author Commented:
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
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
bill201Author Commented:
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
 
NorieVBA ExpertCommented:
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
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Are you absolutely sure the web document is the same (i.e. that "frmLogin$UserName" exists)?
0
 
bill201Author Commented:
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
 
bill201Author Commented:
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
 
NorieVBA ExpertCommented:
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
 
bill201Author Commented:
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
 
NorieVBA ExpertCommented:
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
 
bill201Author Commented:
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
 
NorieVBA ExpertCommented:
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
 
bill201Author Commented:
no, i don't change nothing it's just don't fill the form, what browser do you use?
0
 
bill201Author Commented:
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
 
NorieVBA ExpertCommented:
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
 
bill201Author Commented:
yes its a valid login, and when i fill the details manually, i log in
0
 
bill201Author Commented:
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
 
NorieVBA ExpertCommented:
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
 
bill201Author Commented:
yes the password is filled out and i'm able to login.
0
 
NorieVBA ExpertCommented:
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
 
bill201Author Commented:
No I don't get  any message before I click On the login button.
0
 
NorieVBA ExpertCommented:
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
 
bill201Author Commented:
because i don't  attached here the correct login information  (i can send it to you privately the login details
0
 
bill201Author Commented:
now its working thanks a million
0
 
bill201Author Commented:
full and exact answer, thank you and thanks for every one that tried to help
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.