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="{"enabled":true,"emptyMessage":"","validationText":"TESTVALUE","valueAsString":"TESTVALUE"}">
VBA code for link click:
IE.Document.getElementById(runReportID).Click