Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Posts
    5

    Unanswered: Error 424, Object Required?

    I get this error with the following VB code in Access. This is required to transfer data from an Excel spreadsheet to a table in Access and time stamp the entry in the specified field. Any ideas?

    Steve

    Private Sub Command29_Click()
    Dim dbsrail As DAO.Database
    Dim rsdata As DAO.Recordset
    Dim DateStamp As Date
    Set dbsrail = CurrentDb()
    Set rsdata = dbsrail.OpenRecordset("DATA_TABLE", dbOpenTable)
    rsdata.MoveFirst
    Do While Not rsdata.EOF
    If CurrentDb.TableDefs("DATA_TABLE").Fields("TIME") Is Null Then
    [DateStamp] = Now
    TIME = DateStamp
    Me.TIME.Visible = True
    End If
    rsdata.MoveNext
    Loop
    DoCmd.TransferSpreadsheet acImport, 8, _
    "DATA_TABLE", "E:\Databases2\LateTrains.xls", True
    rsdata.Close
    Exit_Command29_Click:
    End Sub

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    you have some serious errors in recordset handling...

    consider:

    Private Sub Command29_Click()
    Dim dbsrail As DAO.Database
    Dim rsdata As DAO.Recordset
    Dim DateStamp As Date
    Set dbsrail = CurrentDb()
    Set rsdata = dbsrail.OpenRecordset("DATA_TABLE", dbOpenTable)
    rsdata.MoveFirst
    Do While Not rsdata.EOF

    if isnull(rsdata!TIME) Then...etc

    refer to your recordset fields as
    rsdata!nameOfThefield

    as in:
    rsdata.edit 'a crucial step if you want to edit data in the recordset(...table)
    rsdata!timestamp = now()
    rsdata.update 'equally crucial to save your edits to the recordset (...table)

    or

    aVariableValue = rsdata!fieldValue
    'no need for .edit/.update to simply read the data in the recordset.

    fix the recordset read/write, and get back to us if there are other issues yoou can't fix.


    izy


    izy
    Last edited by izyrider; 05-17-04 at 17:37.
    currently using SS 2008R2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •