J
Jan
Hi
I have a database that I use to keep track of the sales promotions that we
send to companies.
I normally send a mailing based on a subset of the companies in the database
(found using the query: QryICTMassDistribution3) , I then use a form and
the code below to create a new record in the corrispondence table to show
what corrispondence has been sent to various companies.
However, when I tried this for our latest mailing it only worked for 52 of
348 the records.
The QryICTMassDistribution3 query, links several tables, and returns 348
records when run normally but in the code below the recordset only seems to
have 52 records.
Can anyone suggest where I have gone wrong?
Many thanks
JM
the code:
Private Sub Command0_Click()
Dim cnxn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cnxn = CurrentProject.Connection
Set rs = New ADODB.Recordset
Set linktable = New ADODB.Recordset
Dim count As Integer
rs.Open "Select Count(*) As MatchCount FROM QryICTMassDistribution3", cnxn
linktable.Open "TblCompanyId_Correspondence", cnxn, adOpenKeyset,
adLockOptimistic
rs.MoveFirst
MsgBox "you are about to process " & rs!MatchCount & " records"
count = 0
While Not rs.EOF
count = count + 1
linktable.AddNew
linktable.Fields("CompanyId") = rs.Fields("CompanyId")
linktable.Fields("CorespondenceId") = Text5.Value
rs.MoveNext
Wend
rs.Close
MsgBox count & " records added to corrispondence table"
Set rs = Nothing
linktable.Update
linktable.Close
Rem Set linktable = Nothing
End Sub
I have a database that I use to keep track of the sales promotions that we
send to companies.
I normally send a mailing based on a subset of the companies in the database
(found using the query: QryICTMassDistribution3) , I then use a form and
the code below to create a new record in the corrispondence table to show
what corrispondence has been sent to various companies.
However, when I tried this for our latest mailing it only worked for 52 of
348 the records.
The QryICTMassDistribution3 query, links several tables, and returns 348
records when run normally but in the code below the recordset only seems to
have 52 records.
Can anyone suggest where I have gone wrong?
Many thanks
JM
the code:
Private Sub Command0_Click()
Dim cnxn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cnxn = CurrentProject.Connection
Set rs = New ADODB.Recordset
Set linktable = New ADODB.Recordset
Dim count As Integer
rs.Open "Select Count(*) As MatchCount FROM QryICTMassDistribution3", cnxn
linktable.Open "TblCompanyId_Correspondence", cnxn, adOpenKeyset,
adLockOptimistic
rs.MoveFirst
MsgBox "you are about to process " & rs!MatchCount & " records"
count = 0
While Not rs.EOF
count = count + 1
linktable.AddNew
linktable.Fields("CompanyId") = rs.Fields("CompanyId")
linktable.Fields("CorespondenceId") = Text5.Value
rs.MoveNext
Wend
rs.Close
MsgBox count & " records added to corrispondence table"
Set rs = Nothing
linktable.Update
linktable.Close
Rem Set linktable = Nothing
End Sub