Results 1 to 6 of 6
  1. #1
    ctgann is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2011
    Posts
    4

    Web Browser Control

    I am using Microsoft Access 2007 and using a Web Browser Control on a form. I am writing data from text fields on the form to the form inside the web browser control. The following scenario works fine using the following code: “i.e. MedID on Access form goes to Web Form id_mediciad”



    <tr><td title="Member ID" nowrap="nowrap">Member ID*</td><td style="padding-left: 4px">
    <input datafld="sak_recip" size="10" id="input_sak_recip" disabled="disabled" style="display: none" /><table datasrc="#RequestIsland" datafld="physHdrKey" style="display: inline"><tr><td>
    <input datafld="rid" size="13" maxlength="12" onchange="handleRecipientPhys(this);"id="id_medica id" /></td> </tr></table></td></tr>


    Private Sub cmdSetHTMLClaim_Click()
    Dim data As String
    If IsNull(Me.MedID) Then
    data = ""
    Else
    data = Me.MedID
    End If
    SetBrowserData "SetTextboxValue", data
    End Sub

    Private Sub SetBrowserData(ByVal FunctionName As String, ByVal data As String)
    wbInstance.Document.GetElementByID("id_medicaid"). Value = data
    While wbInstance.Busy
    DoEvents
    Wend
    End Sub

    My problem is when I try the same code and try to write data to the datafld=”cde_diag” it does not work. Do you have any ideas of how to do this or what I am doing wrong?

    <table id="diag">
    <thead /><tr><td valign="top"> <div style="margin-top: 6px">Diagnosis</div></td><td> <div style="height: 115px; overflow-y: auto" class="clsCollapsed"><table border="0" dataFld="diag_xref" dataSrc="#RequestIsland"><tbody><tr> <td nowrap="nowrap"> <select size="1" datafld="seq">
    <option value="1">Principle</option>
    <option value="2">Other 2</option>
    </select></td><td align="center"><input datafld="sak_diag" style="display: none" /><input datafld="cde_diag" size="5" maxlength="5" onchange=" validateAndAddNewRow( this, diagnosisLookup, diag_IslandObj, 'seq' ); " /></td></tr></tbody></table></div></td></tr></table>

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    what is that HTML code from? the webpage's source inside the browser control? where did you get it? It doesn't look like typical html tag properties. can you explain that first pls? at least for me, I'm not getting that. thanks!

    furthermore, if you look at the html, you can see that the <input> with datafld=”cde_diag”, that input element has no ID property associated with it, which is probably why your called function is not working. You obviously can't use the method:
    Code:
    document.getElementById("tag").value
    when the tag has no ID assigned to it.

    also, you might try other methods like:
    Code:
    getElementsByTagName
    or, even use collections with the [] symbols to refer to the array placement of the actual tag. That also works, I know it does in the DOM, but if I remember right, it does not work in VBA. Worth a try though.

  3. #3
    ctgann is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2011
    Posts
    4
    The web page source code is from the web page inside the browser control. I tried the GetElementsByTagName, didn't work. I am really frustrated. The input element has no id. The Web Page comes from https://www.ohcaprovider.com/Oklahom...ty/logon.xhtml . Of course the logon page has id's in it, it is just the rest that does not. What are the [] symbols your talking about and how does it look when you use them?

    Thanks

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by ctgann View Post
    What are the [] symbols your talking about and how does it look when you use them?

    Thanks
    it's just another method of the DOM. (document object model).

    You can learn all the methods and syntaxes from W3schools. for this one: http://www.w3schools.com/Dom/met_doc...sbytagname.asp

    The [] brackets are used in the DOM to indicate an array value (base 0) when a collection is referenced. For instance, as in the example they show you on that page above.

    another example would be the links in a page. So that would refer to the "<a>" tags that are in any given page's HTML. So, for instance, if I wanted to get the actual words that display on the screen that refer to a hyperlink - the 5th hyperlink in the page's HTML (from top to bottom), I would write this:
    HTML Code:
    myvariable = document.links[4].innerhtml

  5. #5
    ctgann is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2011
    Posts
    4
    I tried that and still no luck, and other ideas? i.e. an example?

  6. #6
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    it's been 2 days here, but if I remember, the problem was the fact that some input tags have no ID attribute, right?

    why don't you just reference the actual tag number in the:
    Code:
    document.all()
    collection??

    for instance, put a value in the box that you want to identify and loop the page's tags like this:
    Code:
    Dim x As Long
    dim var as variant
    
    x = 0
    
    Do
       var = BROWSERCONTROL.Document.All(x).value
            x = x + 1
                If var = YOUR VALUE Then
                    Debug.Print x & " - " & var
                        'exit sub or function here
                End If
    Loop
    X will tell you the pos. Then, you've got the code you want:
    Code:
    BROWSERCONTROL.Document.All(Whatever X Was).value
    but of course, the cheater way like this will stop working if the number of tags on the page is changed by the webmaster, or if the tags are re-ordered.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 03-14-2011, 09:37 AM
  2. Web Browser Control Problem
    By ctgann in forum Forms
    Replies: 0
    Last Post: 03-06-2011, 06:09 AM
  3. Drag n Drop BETWEEN textbox and web browser
    By kirklandwater123 in forum Programming
    Replies: 4
    Last Post: 10-29-2010, 01:23 AM
  4. Active X - Web Browser control doesn't work
    By forstatd in forum Reports
    Replies: 1
    Last Post: 06-02-2010, 10:56 PM
  5. Sending control to specific control
    By wasim_sono in forum Programming
    Replies: 2
    Last Post: 04-19-2007, 08:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums