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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Edit a recordset

Status
Not open for further replies.

Schaap

Technical User
Jul 6, 2004
54
NL
When I edit a recordset, it will be at the first record of the database instead of the selected recordset, selected by IndexNumber.

Code:
Dim Db As Database
Dim Rs As Recordset

Set Db = CurrentDb()
Set Rs = Db.OpenRecordset("select Offer, EstimatedPrice From Investmentplanning order by IndexNumber;")

With Rs
.Edit
!Offer = Me.NewOffer
!EstimatedPrice = Me.NewEstimatedPrice
.Update
Rs.Close
Set Rs = Nothing

What do I do wrong ?
 
You haven't done more than specifying the sort order of the recordset. If you want it to "go to" a specific record, issue a .FindFirst, else specify a where condition:

[tt]Set Rs = Db.OpenRecordset("select Offer, EstimatedPrice From Investmentplanning where IndexNumber=" & me!txtIndexNumber)[/tt]

- assuming you have a control on the form to retrieve the index number from. This is assuming the field is numeric, else add single quotes: [tt]...IndexNumber='" & me!txtIndexNumber & "'")[/tt]

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top