• No. of records in table? (Access2k)

    Author
    Topic
    #365813

    Hi,
    From your code, I assume there’s nothing in the table prior to the import? If that’s the case, using rst.recordcount should get you the number of records imported.
    Hope that helps.

    Viewing 0 reply threads
    Author
    Replies
    • #565484

      Is there any way I could count the no of records in a table and display it by using code??
      I’ve already got the following code and want to add some code to display how many records have been exported into the table called tblMiscData.

      Sub ImportMiscData()
      Dim db As DAO.Database
      Dim rst As DAO.Recordset
          'Turn System warnings off
          Application.SetOption "Confirm Action Queries", False
          'Delete table contents
          DoCmd.OpenQuery "DELtblMiscData", acNormal, acEdit
          'Import data
          DoCmd.TransferSpreadsheet acImport, 8, "tblMiscData", "T:TradeAdminSysMiscData.xls", True, ""
          Set db = CodeDb
          Set rst = db.OpenRecordset("tblMiscData")
              If rst.BOF And rst.EOF Then
                  MsgBox "Data has not been imported from MiscData.xls, Please check and try again!",  _
                             vbInformation + vbMsgBoxSetForeground, strMsgTitle
              Else
                  MsgBox "Finished importing data!", vbInformation + vbMsgBoxSetForeground, strMsgTitle
                  DoCmd.OpenQuery "UpdMiscTT", acNormal, acEdit
                  'Add last tnum
                  DoCmd.OpenQuery "DELTnum", acNormal, acEdit
                  DoCmd.OpenQuery "AppTnum", acNormal, acEdit
                  DoCmd.OpenForm "frmTnum", acNormal, "", "", acEdit, acNormal
              End If
          'Turn System warnings on
          Application.SetOption "Confirm Action Queries", True
      End Sub
      

      Edited by Charlotte to eliminate horizontal scrolling

      • #565491

        Done it using the following codes:
        strMessage = rst.RecordCount & ” Records have been imported ”
        MsgBox strMessage
        joy

    Viewing 0 reply threads
    Reply To: No. of records in table? (Access2k)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: