Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add/Edit/Delete Record(s) 1

Status
Not open for further replies.

air1access

Technical User
Jan 27, 2008
123
US
I am stumped..
I have to recordsets (RS). One is a base and the other is a varying RS. The example below does just fine for adding a new record to the base RS or editing a record in the base RS. But what I can't figure is how to delete a record from the base RS when that matching record is NOT in the varying RS. The varying RS recordcount changes all the time - so when there is more records in the varying RS - they need to be added to the base RS, when there is less - they need to be deleted from the base RS, and when there is a match - they need to be edited...
Any examples or suggestions as to how I can get the code posted below to "make it happen"...?? I sure to appreciate it and thank ya in advance...!!!
Regards - air1access

My example -

rstVarying.MoveFirst
Do Until rstVarying.EOF = True
rstBase.FindFirst "[IID] = '" & rstVarying!IID & "'"
If rstBase.NoMatch Then
rstBase.AddNew
rstBase!GTWY = GBLGTWY
rstBase!FLEETTYPE = GBLFleet
rstBase!IID = rstVarying!IID
rstBase!FleetEff = rstVarying!FLEETTYPE
rstBase.Update
Else
rstBase.Edit
rstBase!GTWY = GBLGTWY
rstBase!FLEETTYPE = GBLFleet
rstBase!IID = rstVarying!IID
rstBase!FleetEff = rstVarying!FLEETTYPE
rstBase.Update
End If
rstVarying.MoveNext
Loop
 
Add the following code:
Code:
rstBase.MoveFirst
Do Until rstBase.EOF = True
rstVarying.FindFirst "[IID] = '" & rstBase!IID & "'"
If rstVarying.NoMatch Then
  rstBase.Delete
End If
rstBase.MoveNext
Loop

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV,

Simple as that..!! That did exactly what I needed...
Thank you..!!

air1access
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top