J
Jen
Hi All,
I have two recordsets behind a button, one(rsttbl) is for
a table: tblData, which has SubscriberID,ReStateDate, and
FinishedFlag. another(rst) is for a query,which has
SubscriberID, ReStateDate. What I wanted to do is to
search both SubscriberID and ReStateDate in the tblData
table, if there is a match, then update the tblData table
by flipping the FinishedFlag = Yes. My sample data is
like the following in the table, which includes
duplicated SubscriberIDs, but with different RestateDates:
SubscriberID RestateDate FinishedFlag
S00003128 3/23/2004 No
S00007513 5/6/2004 Yes
S00014601 2/3/2004 No
S00014601 5/6/2004 No
S00014601 4/3/2004 No
S77777777 5/6/2004 No
S88888888 5/6/2004 No
But right now I have the following codes, they are not
working correctly, Can anyone help me to take a look at
the codes below and give me some suggestions? Thank you
very much for any help! Jen
Set rsttbl = db.OpenRecordset("tblData",
dbOpenDynaset) 'for tblData
Set rst = db.OpenRecordset("qryExtractData",
dbOpenDynaset) 'for qryExtractData
If rst.EOF And rst.BOF Then
MsgBox "You do not have any data in the
table. " , vbOKOnly, "ABC"
Else
rst.MoveLast
intCount2 = rst.RecordCount
rst.MoveFirst
strSearch = "[SubscriberID]= " & QUOTE & rst!
SubscriberID & QUOTE
rsttbl.MoveFirst
rsttbl.FindFirst strSearch
For intCount1 = 1 To intCount2
If Not rsttbl.NoMatch And intCount1 = 1 Then
strSearch2 = "[RestateDate]= # " & rst!
RestateDate & "#"
rsttbl.FindFirst strSearch2
If Not rsttbl.NoMatch Then
rsttbl.Edit
rsttbl!Completed = True
rsttbl.Update
End If
Else
rsttbl.MoveFirst
rst.MoveNext
strSearch = "[SubscriberID]= " & QUOTE &
rst!SubscriberID & QUOTE
rsttbl.FindNext strSearch
If Not rsttbl.NoMatch And intCount1 > 1 Then
strSearch2 = "[RestateDate]= # " & rst!
RestateDate & "#"
rsttbl.FindNext strSearch2
If Not rsttbl.NoMatch Then
rsttbl.Edit
rsttbl!Completed = True
rsttbl.Update
End If
End If
End If
Next intCount1
End If
I have two recordsets behind a button, one(rsttbl) is for
a table: tblData, which has SubscriberID,ReStateDate, and
FinishedFlag. another(rst) is for a query,which has
SubscriberID, ReStateDate. What I wanted to do is to
search both SubscriberID and ReStateDate in the tblData
table, if there is a match, then update the tblData table
by flipping the FinishedFlag = Yes. My sample data is
like the following in the table, which includes
duplicated SubscriberIDs, but with different RestateDates:
SubscriberID RestateDate FinishedFlag
S00003128 3/23/2004 No
S00007513 5/6/2004 Yes
S00014601 2/3/2004 No
S00014601 5/6/2004 No
S00014601 4/3/2004 No
S77777777 5/6/2004 No
S88888888 5/6/2004 No
But right now I have the following codes, they are not
working correctly, Can anyone help me to take a look at
the codes below and give me some suggestions? Thank you
very much for any help! Jen
Set rsttbl = db.OpenRecordset("tblData",
dbOpenDynaset) 'for tblData
Set rst = db.OpenRecordset("qryExtractData",
dbOpenDynaset) 'for qryExtractData
If rst.EOF And rst.BOF Then
MsgBox "You do not have any data in the
table. " , vbOKOnly, "ABC"
Else
rst.MoveLast
intCount2 = rst.RecordCount
rst.MoveFirst
strSearch = "[SubscriberID]= " & QUOTE & rst!
SubscriberID & QUOTE
rsttbl.MoveFirst
rsttbl.FindFirst strSearch
For intCount1 = 1 To intCount2
If Not rsttbl.NoMatch And intCount1 = 1 Then
strSearch2 = "[RestateDate]= # " & rst!
RestateDate & "#"
rsttbl.FindFirst strSearch2
If Not rsttbl.NoMatch Then
rsttbl.Edit
rsttbl!Completed = True
rsttbl.Update
End If
Else
rsttbl.MoveFirst
rst.MoveNext
strSearch = "[SubscriberID]= " & QUOTE &
rst!SubscriberID & QUOTE
rsttbl.FindNext strSearch
If Not rsttbl.NoMatch And intCount1 > 1 Then
strSearch2 = "[RestateDate]= # " & rst!
RestateDate & "#"
rsttbl.FindNext strSearch2
If Not rsttbl.NoMatch Then
rsttbl.Edit
rsttbl!Completed = True
rsttbl.Update
End If
End If
End If
Next intCount1
End If