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

3
  • Is there specific reason why all your buttons have the same name? Commented Feb 7, 2017 at 16:19
  • Don't know why as the web page I'm accessing is an existing one of which I have no control! Commented Feb 7, 2017 at 16:22
  • Not sure if this link is helpful: stackoverflow.com/questions/8926378/… 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? Commented Feb 7, 2017 at 16:29

1 Answer 1

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

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.