[AccessD] ADO Record Counts

Jeremy Toves itsame2000 at sbcglobal.net
Wed Feb 2 11:29:15 CST 2005


Can somebody tell me what is wrong here?  I am trying to change from using DAO to ADO.  I've seen where several of you use ADO.  
 
I'm writing filenames to an archive table.  If the file I'm looking at doesn't exist in the archive table, then I would append.  I get a -1 for the record count, whether there is a match or not to the file I'm evaluating.  Here is a sample of what I'm running.  
 
Thanks,
Jeremy Toves  
 
**************************************************************
 
Sub Suspense_File_Recon
   Dim cn As ADODB.Connection
   Dim rs As ADODB.Recordset
   Dim strSQL As String, strFile As String
 
  Set cn = CurrentProject.Connection
  Set rs1 = New ADODB.Recordset
 
  strFile = "File1.txt"
 
  strSQL = "SELECT " _ 
                      & "tblFileArchive.* " _ 
                & "FROM " _ 
                       & "tblFileArchive " _ 
                & "WHERE " _ 
                        & "(((tblFileArchive.txtFilename)=" & Chr(34) & strFile & Chr(34) & "));"
           
   rs1.Open _
         strSQL, _
         cn, _ 
         adOpenDynamic, _
        adLockOptimistic
 
   If rs1.RecordCount < 1 Then '================> Here is where the recordcount _
                                                                                works with DAO but not ADO.
       rs1.AddNew
       rs1!txtFilename = strFile
       rs1!Update
   End If
 
   rs1.Close
   cn.Close
 
   Set rs1 = Nothing
   Set cn = Nothing
 
End Sub
 
 



More information about the AccessD mailing list