Results 1 to 11 of 11
  1. #1
    BallinWallin is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    11

    Trouble Pulling Values from the Internet

    Hello,

    In short: I am trying to populate tables with values pulled from the internet.

    Here is the problematic portion of my code (I apologize for being a noob at formatting on this forum):
    ************************************************** *
    'Open IE
    Dim ie As Object
    Set ie = CreateObject("internetexplorer.application")
    ie.Visible = True

    'Navigate and Record Values
    With secondary
    .MoveFirst
    Do While Not .EOF
    Manufacturer = .Fields("manufacturer").Value
    Model = .Fields("model").Value
    amzurl = .Fields("amazon url").Value
    neggurl = .Fields("newegg url").Value
    ie.navigate amzurl
    While ie.busy
    DoEvents


    Wend
    Me.Price.Value = ie.Document.getElementById("priceLarge").Value
    Exit Do
    Loop
    End With
    ********************************************
    I know there are all kinds of problems but my concern is the line "Me.Price.Value = ie.Document.getElementById("priceLarge").Value" because that's where my code gets hung (Runtime Error 91: Object variable or with block variable not set). The page successfully opens and loads but when that line tries to read a value it gives the mentioned error.

    I've googled and googled trying to find how to fix this and it's not working. Thank you for your help.

  2. #2
    goodguy is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Location
    Zanzibar, Tanzania
    Posts
    229
    You need to declare and initialize a variable for 'ie'.

  3. #3
    BallinWallin is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    11
    Is that not what I did up in the line "Dim ie As Object"? Or is there some other kind of declaration needed? As I mentioned, the code successfully opens Internet Explorer and navigates to the desired page; I simply do not know how to read values from that page.

  4. #4
    goodguy is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Location
    Zanzibar, Tanzania
    Posts
    229
    Sorry, I had not noticed the top lines of code. I googled GetElementByID and found that it is a method of javascript used with XML documents whereas you say you want to pull values from the internet.
    Did you write this code or did you copy it from somewhere?
    Do you have an XML document that holds the data?
    What value are you trying to retrieve with this method?

  5. #5
    BallinWallin is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    11
    This is where I got it from: http://www.access-programmers.co.uk/...d.php?t=176968
    I just sorta figured that since the first pieces of code from this page worked that the rest might.

    What I'm trying to do is have a form automate the process of pulling prices from webpages and storing them in tables. As you can see from the code, the two websites I am currently pulling from are Amazon and Newegg.

    Thank you for your help.

  6. #6
    goodguy is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Location
    Zanzibar, Tanzania
    Posts
    229
    Try using "Me!" instead of "Me.":
    Code:
    Me!Price = ie.Document.getElementById("priceLarge").Value

  7. #7
    BallinWallin is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    11
    I made that change and it still gives the same error. What does an ! point do exactly?

  8. #8
    goodguy is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Location
    Zanzibar, Tanzania
    Posts
    229
    Controls on the form are referenced as follows:
    Code:
    Forms!frmThisForm!thisControl
    or
    Code:
    Form.("frmThisForm").("thisControl")
    "Me" returns the form object itself, so if the form you are referring to is the same one in which you are writing the code, then you could shorten it to:
    Code:
    Me."thisControl"
    or
    Code:
    Me!thisControl
    It would seem to me you do not have a control named "Price" on your form.
    Could you check and confirm?

  9. #9
    BallinWallin is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    11
    Oh ok, I see. Thank you.

    No, I do have a textbox that is named Price. I've tried that specific line of code in several other ways, such as assigning the value to a variable instead of directly outputting it to the textbox.

    This is really killing me.

  10. #10
    BallinWallin is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    11
    Well I believe I have made some slight progress. I removed the ".value" from the end of the GetElementByID statement and I no longer get an error. I still can't get a value to be pulled from the web page though. I am able to get "[Object]" to be placed in the Price textbox but it's not pulling the actual value. That's from the Amazon page, I can't get anything to come from the Newegg page.

  11. #11
    goodguy is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Location
    Zanzibar, Tanzania
    Posts
    229
    Can you test the statement with different elementid's from other URLs?

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

Similar Threads

  1. Pulling two most recent values (MAX)
    By AquaLady42 in forum Access
    Replies: 4
    Last Post: 07-22-2011, 08:04 AM
  2. Pulling values from a table
    By billdavidson in forum Programming
    Replies: 3
    Last Post: 05-16-2011, 11:44 AM
  3. Replies: 0
    Last Post: 03-28-2011, 05:06 PM
  4. Replies: 3
    Last Post: 12-21-2010, 11:52 AM
  5. pulling text values into FK number column
    By REBBROWN in forum Database Design
    Replies: 2
    Last Post: 08-30-2010, 05:04 PM

Tags for this Thread

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