Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access scrape, tbl not updating 2

Status
Not open for further replies.

brh4j1

Technical User
Oct 18, 2011
3
US
Hello, I am scraping data fields from Attachmate Reflection into MS Access with the following VB macro. The macro runs fine, the data is correct and it gives a completion message; however, it is not updating my table with the data. Any ideas why?

P.S
I include 'MS DAO 3.6 Object library' in my References

Code:
Option Compare Database
Option Explicit

Private Sub Start_Conversion_Click()
On Error GoTo Err_Start_Conversion_Click
On Error GoTo 0
Dim reflection As Object
    Set reflection = GetObject("RIBM")
    reflection.Connect

'** Prepare the database:
 
   Dim db As DAO.Database
   Dim rs As DAO.Recordset
   Dim i As Integer
   Dim TIME_STARTED, TIME_COMPLETED
   Dim varLineCounter As Long

    TIME_STARTED = Time()

    Set db = CurrentDb
    Set rs = db.OpenRecordset("testdb")
    
   DoEvents
      
'** Start the main loop:

       With reflection

                 
'PULL DATA
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
         varLineCounter = 1
         Do While varLineCounter < 24
            varLineCounter = varLineCounter + 1
         If IsNumeric(.getdisplaytext(varLineCounter, 116, 4)) Then
'         MsgBox "yes " & varLineCounter & " " & .getdisplaytext(varLineCounter, 34, 35)
            rs.AddNew
            rs!Data0 = .getdisplaytext(varLineCounter, 9, 9)
            rs!data1 = .getdisplaytext(varLineCounter, 23, 9)
            rs!data2 = .getdisplaytext(varLineCounter, 34, 35)
            rs!data3 = .getdisplaytext(varLineCounter, 75, 13)
            rs!data4 = .getdisplaytext(varLineCounter, 95, 13)
         Else
         End If
         Loop
                          
'***** END OF MACRO **************
          
         On Error Resume Next
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
         On Error GoTo 0
            
FINISH:
   
   rs.Close
     
   TIME_COMPLETED = Time()
   
   MsgBox "PROCESS COMPLETED !!!!"
  
Exit_Start_Conversion_Click:
    Exit Sub

Err_Start_Conversion_Click:
    MsgBox Err.Description
    Resume Exit_Start_Conversion_Click
End With
End Sub
 

How about rs.Update?

Nothing gets written to the file until you use the Update Method.

Code:
...
rs.AddNew
rs!Data0 = .getdisplaytext(varLineCounter, 9, 9)
rs!data1 = .getdisplaytext(varLineCounter, 23, 9)
rs!data2 = .getdisplaytext(varLineCounter, 34, 35)
rs!data3 = .getdisplaytext(varLineCounter, 75, 13)
rs!data4 = .getdisplaytext(varLineCounter, 95, 13)
rs.Update
...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top