1

Fellows,

I was trying to do IE automation with VBA. Everything worked as I wanted until I got to this problem. Enter item no in a input text filed, and then click on link 'RUN Report' to get the report.

Problem: After clicked on 'RUN report', the report was not pulled for the Item No I entered in the text filed. But a report for all items in database.

Possible cause: There is a onclick function in the link, I am not sure if this function is called when "IE.Doucument.getElementById(runReportID).Click" is executed. I also tried "IE.Document.getElementById(runReportID).FireEvent("onclick")" and "IE.Document.parentWindow.execScript("return ValidateDate();", "JavaScript")", unfortunately, they didn't work.

And I don't know how to pass the value I entered in text field to the function when "Run Report" button is clicked. Is there an event in that text filed to do this job?

HTML code for link 'RUN Report' and text field:

<A onclick="return ValidateDate();" id=spsCtrlDefault_ctl02_lbtn_run_qry_rpt title="Click to run report" style="CURSOR: hand; TEXT-DECORATION: none; HEIGHT: 14px; FONT-FAMILY: ariel; FONT-WEIGHT: bold; COLOR: #0033ff" href="javascript:__doPostBack('spsCtrlDefault$ctl02$lbtn_run_qry_rpt','')">[ Run Report ]</A>
<input id="spsCtrlDefault_ctl02_gvQueryColumns_ctl02_txtItem_Code" name="spsCtrlDefault$ctl02$gvQueryColumns$ctl02$txtItem_Code" size="20" class="riTextBox riEnabled" type="text" req_ind="N" tbl_idn="2" value="947519" controltype="text" datatype="varchar" col_idn="1" dbfld="item_revision.item_cde" style="text-transform: uppercase;">
<input id="spsCtrlDefault_ctl02_gvQueryColumns_ctl02_txtItem_Code_ClientState" name="spsCtrlDefault_ctl02_gvQueryColumns_ctl02_txtItem_Code_ClientState" type="hidden" autocomplete="off" value="{&quot;enabled&quot;:true,&quot;emptyMessage&quot;:&quot;&quot;,&quot;validationText&quot;:&quot;TESTVALUE&quot;,&quot;valueAsString&quot;:&quot;TESTVALUE&quot;}">

VBA code for link click:

IE.Document.getElementById(runReportID).Click

1 Answer 1

1

I finally figured it out!!!

There is a hidden text input element there to capture the value I entered in the text filed. Every time the text filed loses focus, the value in the text filed will be sent to the hidden input element below.

<input id="spsCtrlDefault_ctl02_gvQueryColumns_ctl02_txtItem_Code_ClientState" name="spsCtrlDefault_ctl02_gvQueryColumns_ctl02_txtItem_Code_ClientState" type="hidden" autocomplete="off" value="{&quot;enabled&quot;:true,&quot;emptyMessage&quot;:&quot;&quot;,&quot;validationText&quot;:&quot;TESTVALUE&quot;,&quot;valueAsString&quot;:&quot;TESTVALUE&quot;}">

VB Code for sending value to hidden input element:

queryID = "spsCtrlDefault_ctl02_gvQueryColumns_ctl02_txtItem_Code"
IE.Document.getElementById(queryID).FireEvent ("onblur")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.