Problem with field names on a webpage

Chiggers5

New member
Local time
Today, 20:49
Joined
Dec 31, 2013
Messages
7
Forgive me if this is in the wrong place and feel free to move if it is. It may also be more of an HTML problem than a VBA one, but here goes...

I am using Access 2007 to update a page on an external website (amongst other things) from an Access form using VBA, but that page has recently changed. I have dealt with most of the issues around this, but there is still a problem that I cannot see how to resolve. Previously all the fields on the page were uniquely named, and so I was able to assign values from my form to them using
Code:
.document.all.item(fieldname).value=...
But now there appear to be identically named fields on the webpage and I cannot see how to differentiate between them in my code. I have attached a text file with the two relevant sections, containing the HTML for the two relevant sections on that page only (the code for the whole page runs to 8000+ lines and I can add the lot if really necessary) and as you will see the names for things like runs (name="result[][runs]") and wickets ("result[][wickets]") are the same in both sections. So how do I tell one from the other in my code?

Currently I have the following:
Code:
    With objIE
        .Visible = True
....
'1st innings - new HTML field names but duplicated on the webpage
        .Document.all.Item("result[][runs]").value = nz(Me![runs_for#])
        .Document.all.Item("result[][wickets]").value = nz(Me![wickets_for#])
        .Document.all.Item("result[][overs]").value = nz(Me!ovf)
...
'2nd innings - still old HTML field names
        .Document.all.Item("runs2").value = nz(Me![runs_against#])
        .Document.all.Item("wickets2").value = nz(Me![wickets_against#])
        .Document.all.Item("overs2").value = nz(Me!ova)
...
        End With
If you can follow all that, then please, can anyone help? How can I differentiate between the HTML field names in the attached file as simply as possible in my code above?
 

Attachments

Last edited:
Pure guesswork on my part but the primary difference between the two lines in your file is the id

id="match_fixture_toss_25184"
id="match_fixture_toss_14779"
from the previous line and on the line itself
<input id="result__team_id" name="result[][team_id]" type="hidden" value="25184" />
<input id="result__team_id" name="result[][team_id]" type="hidden" value="14779" />

This implies that the page is showing more than one result, so presumably you need to do the same?

Not sure how you would code it, but perhaps you need to go up one 'level' to an inputID
 
Many thanks for the response CJ - I had looked at that as a possibility but have no idea how I might code it. I was hoping there might be a way of specifying the 'level' for the relevant fieldname within the .Document statement, but my research thus far has drawn a blank - hence the query. It may well be that I shall have to resort to searching through the code looking for the relevant <input tag and value and then working from there, but I thought that there might be a more elegant solution out there that someone else knows about.

I have a couple of months or so before I absolutely have to re-code this, so I can live in hope a little longer yet!
 

Users who are viewing this thread

Back
Top Bottom