-
How can I just move thought a recordset and update records which meet my criteria, it updates the whole file.
This is what I am doing.
Dim cn1 As ADODB.Connection
Dim rs1 As ADODB.Recordset
Set cn1 = New ADODB.Connection
cn1.ConnectionString = "Provider=MSDASQL.1;" _
& "Persist Security Info=False;" _
& "DSN=Visual FoxPro Tables;" _
& "UID=;" _
& "PWD=;" _
& "SourceDB=c:\ado;" _
& "SourceType=DBF;" _
& "Exclusive=No;" _
& "BackgroundFetch=Yes;" _
& "Collate=Machine;" _
& "Null=Yes;" _
& "Deleted=Yes;"
If cn1.State = 1 Then
cn1.Close
Else
cn1.Open
End If
cn1.CursorLocation = adUseClient
Set rs1 = New ADODB.Recordset
rs1.Open "SELECT * FROM test", cn1, adOpenKeyset, adLockOptimistic
For x = 1 To rs1.RecordCount
With rs1
!Name = "I know"
.MoveNext
End With
Next x
rs1.Close
cn1.Close
-
Why going to the full table.
Use a WHERE clausule in the SELECT statement.
rs1.Open "SELECT * FROM test WHERE fieldname = '" & yourcriteria & "' ",cn1, adOpenKeyset, AdLockOptimistic
Now you have only those records matching your criteria.
cheers
Ray
-
Nth Select program
Because I built a nth select program, say if I have 100 records and I only want to choose 10 I create a flag field move throught the records and with a fomula calculate 10 out of the 100 and mark the flag field.
I'm having a hard time because when I use this
rs!field = "K"
rs.update
rs.movenext
it updates my whole file.
Bruno