0

I have an HTML page that has multilpe submit buttons with different "value=xxx" parameters. I need to submit the form with the right value via VBA code in MSAccess module!

<form method="post" name="data" action="/data1/infoProjetFO.php" onsubmit="return(checkPQ())" >

<input type="submit" name="Btn" value="SaveRecord">&nbsp;&nbsp;

<input TYPE="submit" name="Btn" VALUE="Distribution" id="idBtnDistribution"    style="visibility:visible;" />&nbsp&nbsp;

'========================================================
 sURL = "http://corp.myintrranet.com/index.php"
 Set tBrowser = GetObject("new:{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}")
tBrowser.navigate sURL


' Wait till the Browser is loaded
Do While tBrowser.Busy Or tBrowser.ReadyState <> 4
    DoEvents
    Debug.Print tBrowser.ReadyState
Loop

' here I have code that can get different values and also insert values with no problem!

'here is what I've tried!
 tBrowser.Document.Forms("data").all("Btn").Value = "SaveRecord"
 tBrowser.Document.Forms("data").all("Btn").Click
' or I tried 
 tBrowser.Document.Forms("data").all("Btn").submit

combinations I've tried to insert the proper submit button value result in trapping error code 438, object doesn't support ....
So I need to click or submit with the right value!

Thanks

Pete

Peter
  • 148
  • 1
  • 2
  • 18
  • Is there specific reason why all your buttons have the same name? – Armin Feb 07 '17 at 16:19
  • Don't know why as the web page I'm accessing is an existing one of which I have no control! – Peter Feb 07 '17 at 16:22
  • Not sure if this link is helpful: http://stackoverflow.com/questions/8926378/how-to-select-an-input-element-by-value-using-javascript If you are using js, you can get value of a button (or button by value). However, you already have onsubmit() method, which I suppose can use that value? – Armin Feb 07 '17 at 16:29

1 Answers1

0

Found the solution!

Set Formtst = tBrowser.Document.getElementsByTagName("input")
For Each btest In Formtst
    If btest.Value = "SaveRecord" Then
      btest.Click
        Exit For
    End If
Next

Thanks

Pete

Peter
  • 148
  • 1
  • 2
  • 18