VBA Access cannot set value on form in web browser that has multiple forms

Elaine

New member
Local time
Yesterday, 23:38
Joined
Dec 5, 2009
Messages
3
Two days of trying to solve this one and now I reach out for help!!!

In Access 2003, I have a module that auto logs into a website, then needs to navigate to a page that has 3 frames and 3 forms, set the select option of a field on the 2nd form of one frame, then submit, automatically. I have tried about a dozen variations of vba from web research and nothing works.
Always I get error "91 Object variable or with block variable not set".

The browser gets created fine, navigates from login page to new page fine.

HTML I am trying to control is in the second form:

<form name="pickReport" action="http://ees.elsevier.com/jpube/prepCustomReport.asp" method='post'>
<table>
<tr align='center'><td>Report: 
<select name="rep" id="rep">
<option selected='selected' value="XX">Choose Report</option>
<option value='15'>Automated use</option>
<option value='14'>Full Data</option>
<option value='13'>Weekly Review Report</option>

</select><br />
</td></tr>
<tr><td> </td></tr>
<tr align='center'>
<td colspan='2'>
<input type="submit" name="submit" value="Run Report" /></td>
</tr>
</table>
</form>

With objIE.Document.Forms("pickReport")
.rep.Value = "15"


VBA follows, with some of the code I have tried, all commented out because they fail

With objIE.Document.Forms("pickReport")
'.Item("rep").Value = "15"
'.rep.Value = "15" ' this works when calling from local customreport.html but not from EES
' objIE.Document.getElementById("rep").Value = "15"

' .elements("rep").Value = "15" '"Automated use"

.submit
End With


Any help is greatly appreciated! Thank you!
Elaine
 
Last edited:
Cleaning up:
PHP:
<form name="pickReport" action="http://ees.elsevier.com/jpube/prepCustomReport.asp" method='post'>
<table>
<tr align='center'><td>Report: 
<select name="rep" id="rep">
<option selected='selected' value="XX">Choose Report</option>
    <option value='15'>Automated use</option>
    <option value='14'>Full Data</option>
    <option value='13'>Weekly Review Report</option>

</select><br />
</td></tr>
<tr><td> </td></tr>
<tr align='center'>
    <td colspan='2'>
        <input type="submit" name="submit" value="Run Report"  /></td>
</tr>
</table>
</form>

            With objIE.Document.Forms("pickReport")
                 .rep.Value = "15" 


VBA follows, with some of the code I have tried, all commented out because they fail 

     With objIE.Document.Forms("pickReport")
               '.Item("rep").Value = "15"
                '.rep.Value = "15"    ' this works when calling from local customreport.html but not from EES
               ' objIE.Document.getElementById("rep").Value = "15"
                
               ' .elements("rep").Value = "15"   '"Automated use"
                
                .submit    
            End With
first of all, have you seen my FAQ? http://www.access-programmers.co.uk/forums/showthread.php?t=176968

if you have not, I suggest reading it.


If you already have then I would say two things:

1) change the form index from ("pickReport"), to the index NUMBER of the form. ie - the number of the form in the order of all of the page elements. for example, from top to bottom of HTML, if there are 5 forms on the page and this one is the third one in the list of all elements in the HTML, then the code is:
PHP:
with objIE.document.forms(2)

2) be aware that SELECT elements have display values and REAL values. for example, between the tags is the display value, and the VALUE attribute is in the code as:
PHP:
value = "VALUE HERE"
try those two solution first.
 
Last edited:
Thanks Adam, but that one is the second in my list of things I tried which didn't work. I think the problem is that the form is in a frame, and reference to fields in the form are not understood unless the frame is referenced. I don't know how to do that.
Elaine
 
Thanks Adam, but that one is the second in my list of things I tried which didn't work. I think the problem is that the form is in a frame, and reference to fields in the form are not understood unless the frame is referenced. I don't know how to do that.
Elaine

what website is it?

and by the way, I learned the other day that frames should not be used in websites because search engines can't index the elements inside of them. (if this is your website, that is)
 
Yes the website uses frames, I know frames have their disadvantages, no it's not my website.

I resolved the problem using code I found here: http://www.mdbmakers.com/forums/showthread.php?t=4265 which steps through the URLs being accessed, their frames and their forms to find the one required.

Thanks for helping Adam. I am SOOO happy this step has been resolved.

Elaine
 

Users who are viewing this thread

Back
Top Bottom