?
Solved

How to save web output via vb code in ms access 2007 table

Posted on 2012-09-04
6
Medium Priority
?
915 Views
Last Modified: 2012-09-27
Hi
I have below code that i need to fix it so that while running it will save the array "aa" value into table "Temp"
currently i am getting error "run time error 13 type mismatch" at the line "Set rs = db.OpenRecordset("Temp", dbOpenDynaset)"

this the code
Private Sub Command38_Click()

    Dim core
    Dim browser
    Set core = CreateObject("openTwebst.Core")
    Set browser = core.StartBrowser("https://www.xxxxxxxxxxxxxxxxxxxxxx/")
    
    Call WaitFor(4)
         
    Call browser.FindElement("input text", "name=username").InputText("xxxxxxx")
    Call browser.FindElement("input password", "name=password").InputText("xxxxxxx")
    Call browser.FindElement("td", "index=5").Click
    Call browser.FindElement("input image", "name=submitted").Click
    
    
    With Me.RecordsetClone
        .MoveFirst
        Do Until .EOF
             Me.Bookmark = .Bookmark
            
            
            Call browser.FindElement("input text", "name=name").InputText(Forms!VSL!name9)
            Call browser.FindElement("input image", "id=startsearch").Click
    
      
             Dim aa
             aa = browser.FindElement("td", "CLASS=message").Text
    
            Dim rr
            rr = browser.FindElement("body", "class=resultlist").Text
    
    
            Dim db As Database
            Dim rs As Recordset
            Set db = CurrentDb()
            Set rs = db.OpenRecordset("Temp", dbOpenDynaset)
            rs.AddNew
                rs!Number = aa
                rs!result = rr
            rs.Update
            rs.Close
            Set rs = Nothing
            Set db = Nothing
            
            Call browser.FindElement("input button", "id=email").Click
            Call WaitFor(1)
            Call browser.FindElement("input text", "name=subject").InputText("Vessel: Transaction Ref. No. - " & Forms!VSL!Ref_no)
            Call browser.FindElement("input text", "name=email").InputText(Forms!VSL!tbtemailto)
            Call browser.FindElement("input submit", "id=email").Click
            
    
            .MoveNext
    
     
        Loop
    End With
    Call browser.FindElement("button", "id=logout").Click
    browser.Close
    
End Sub

Open in new window

0
Comment
Question by:HKH1967
  • 2
  • 2
4 Comments
 

Author Comment

by:HKH1967
ID: 38369254
aikimark
I have not understand the message can you elaborate,thanks
0
 
LVL 46

Expert Comment

by:aikimark
ID: 38369275
Here is another version of the code.  I've moved the Dim statements to the top and moved the initialization/termination statements for the database and the recordset objects out of the loop.

Do you know why the bookmark is being set?
Me.Bookmark = .Bookmark

Private Sub Command38_Click()

    Dim core
    Dim browser
    Dim aa
    Dim rr
    Dim db As Database
    Dim rs As Recordset
    
    Set core = CreateObject("openTwebst.Core")
    Set browser = core.StartBrowser("https://www.xxxxxxxxxxxxxxxxxxxxxx/")
    
    Call WaitFor(4)
         
    Call browser.FindElement("input text", "name=username").InputText("xxxxxxx")
    Call browser.FindElement("input password", "name=password").InputText("xxxxxxx")
    Call browser.FindElement("td", "index=5").Click
    Call browser.FindElement("input image", "name=submitted").Click
    
    Set db = CurrentDb()
    Set rs = db.OpenRecordset("Temp", dbOpenDynaset)
            
    With Me.RecordsetClone
        .MoveFirst
        Do Until .EOF
            Me.Bookmark = .Bookmark
            
            Call browser.FindElement("input text", "name=name").InputText(Forms!VSL!name9)
            Call browser.FindElement("input image", "id=startsearch").Click
      
            aa = browser.FindElement("td", "CLASS=message").Text
            rr = browser.FindElement("body", "class=resultlist").Text
    
            rs.AddNew
                rs!Number = aa
                rs!Result = rr
            rs.Update
            rs.Close
            
            Call browser.FindElement("input button", "id=email").Click
            Call WaitFor(1)
            Call browser.FindElement("input text", "name=subject").InputText("Vessel: Transaction Ref. No. - " & Forms!VSL!Ref_no)
            Call browser.FindElement("input text", "name=email").InputText(Forms!VSL!tbtemailto)
            Call browser.FindElement("input submit", "id=email").Click
            
            .MoveNext
     
        Loop
    End With
            
    Set rs = Nothing
    Set db = Nothing
    
    Call browser.FindElement("button", "id=logout").Click
    browser.Close
    
End Sub

Open in new window

0
 

Author Comment

by:HKH1967
ID: 38369423
aikimark

sorry i do no why.
Do you know why the bookmark is being set?
Me.Bookmark = .Bookmark

I try the code and it generate an error type mismatch
0
 
LVL 46

Accepted Solution

by:
aikimark earned 2000 total points
ID: 38370088
Is the name of the form in which this routine resides Forms!VSL?

If so, then it looks like they are iterating the records of the form, accessing the name9, Ref_no, tbtemailto controls/fields.  Do you notice the form changing records as this routine is run?
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses
Course of the Month13 days, 8 hours left to enroll

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question