jayplus707
Programmer
Hi,
Has anyone had problems with using AddNew in Access 2000 with ADO? I am getting inconsistent results. Sometimes it adds data like it should and other times it doesn't. I put debug.print to make sure the .update was executed so I know it went through the code. However, sometimes data did not add to a local table. I am trying to generate report records before opening a report. The code I use follows.
Thanks,
LLC
Dim rsResults As ADODB.Recordset
Dim rsRptRcds As ADODB.Recordset
Dim intCounter As Integer
gCnn.Execute ("Delete from tblIndivResultsLocal"
Set rsRptRcds = New ADODB.Recordset
rsRptRcds.Open "tblIndivResultsLocal", gCnn, adOpenKeyset, adLockOptimistic
Set rsResults = New ADODB.Recordset
rsResults.Open "tblIndivTestResultsForAppLocal", gCnn
'Generate report records.
Do Until rsResults.EOF = True
If rsResults!Missed = 0 Then
rsRptRcds.AddNew
rsRptRcds!TestResultsID = rsResults!TestResultsID
rsRptRcds!Result = rsResults!Result
rsRptRcds.Update
Debug.Print "update missed 0"
Else
intCounter = 1
Do Until intCounter > rsResults!NoOfQuestions
If rsResults("M" & intCounter) = True Then
rsRptRcds.AddNew
rsRptRcds!TestResultsID = rsResults!TestResultsID
rsRptRcds!Result = rsResults!Result
rsRptRcds!DeficiencyID = rsResults("D" & intCounter)
rsRptRcds.Update
Debug.Print "update missed > 0"
End If
intCounter = intCounter + 1
Loop
End If
rsResults.MoveNext
Loop
rsRptRcds.Close
rsResults.Close
Set rsRptRcds = Nothing
Set rsResults = Nothing
Has anyone had problems with using AddNew in Access 2000 with ADO? I am getting inconsistent results. Sometimes it adds data like it should and other times it doesn't. I put debug.print to make sure the .update was executed so I know it went through the code. However, sometimes data did not add to a local table. I am trying to generate report records before opening a report. The code I use follows.
Thanks,
LLC
Dim rsResults As ADODB.Recordset
Dim rsRptRcds As ADODB.Recordset
Dim intCounter As Integer
gCnn.Execute ("Delete from tblIndivResultsLocal"
Set rsRptRcds = New ADODB.Recordset
rsRptRcds.Open "tblIndivResultsLocal", gCnn, adOpenKeyset, adLockOptimistic
Set rsResults = New ADODB.Recordset
rsResults.Open "tblIndivTestResultsForAppLocal", gCnn
'Generate report records.
Do Until rsResults.EOF = True
If rsResults!Missed = 0 Then
rsRptRcds.AddNew
rsRptRcds!TestResultsID = rsResults!TestResultsID
rsRptRcds!Result = rsResults!Result
rsRptRcds.Update
Debug.Print "update missed 0"
Else
intCounter = 1
Do Until intCounter > rsResults!NoOfQuestions
If rsResults("M" & intCounter) = True Then
rsRptRcds.AddNew
rsRptRcds!TestResultsID = rsResults!TestResultsID
rsRptRcds!Result = rsResults!Result
rsRptRcds!DeficiencyID = rsResults("D" & intCounter)
rsRptRcds.Update
Debug.Print "update missed > 0"
End If
intCounter = intCounter + 1
Loop
End If
rsResults.MoveNext
Loop
rsRptRcds.Close
rsResults.Close
Set rsRptRcds = Nothing
Set rsResults = Nothing