I Lost you post for a while
.........
From your example, I can't tell if the variables have been declared. You
could be affecting a variable that is global.
Looking at the code, it really doesn't matter how many records there are,
only how many records there are where [FDSSelected] = TRUE. If you select
only the records where [FDSSelected] = TRUE, the code will complete sooner.
I've modified your code (untested but should run) - try this on a copy.......
'-------------------------------------------------
Option Compare Database
Option Explicit 'should always have this line
'Public Sub t2()
'you must have a reference set for
' Microsoft DAO 3.6 Object Library
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim sSQL As String
' Import each selected file
Set db = CurrentDb()
sSQL = "SELECT *"
sSQL = sSQL & " FROM SelectedFiles"
sSQL = sSQL & " WHERE [FDSSelected] = TRUE"
Set rs = db.OpenRecordset(sSQL)
'check for records
If Not rs.BOF And Not rs.EOF Then
With rs
.MoveFirst
Do While Not .EOF
Import.StatusBarText = "Importing " & _
!FDSFullPath & "\" & !FDSFileName
Call ImportSelectedFile(!FDSFullPath, !FDSFileName, Me.SCOGroup)
.Edit
!FDSSelected = False
.Update
FDSFNameList = FDSFNameList & !FDSFileName & " "
.MoveNext
Loop
End With
End If
'clean up
rs.Close
Set rs = Nothing
Set db = Nothing
'End Sub
'-------------------------------------------------
HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)
Bill Raterink said:
Jim,
Thanks for the help, but I'm not Access literate enough to know if I'm using
ADO or DAO. Also, I don't know what the connection, Keyset, & lockoptimistic
parameters on your open represent. This program has worked for years, and
all I changed was the import spec to add a field at the beginning of the
record. The spec actually SKIPS this field so the code could stay the same.
I don't think the Spec chg is the issue, since if I set a break point & chg
the Limit back to 370, the program works fine. I just can't see how or why
the record count is doubling. Thanks, -Bill.
JimBurke said:
I'm not sure if you can get an accurate RecordCount with OpenRecordset.
Here's what I've always done that's worked for me:
rst.Open "Query/TableName", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic
rst.MoveLast
rst.MoveFirst
myCount = rst.RecordCount
This is using an ADODB recordset. Not sure if you're using ADO or DAO - I
don't know if the open parms are the same for DAO or not.
I have the following code that should import "selected" file names from a
table.
[quoted text clipped - 26 lines]
Set rs = Nothing
Set db = Nothing