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!

editing records from listbox

Status
Not open for further replies.

goldstar19821982

Programmer
Jan 28, 2008
3
GB
Hello All,

Just had a query with my order system. Currently i have a orderline where you can select a itemid and the details appear, once add has been selected this transfers the data into the listbox.
If i want to edit a record, i want to double click on the record from the listbox and want this to appear within the orderline above so it could be edited. Any ideas on how i can this to appear from the listbox back to the the orderline. This is the code that i have tried.

Private Sub hireDetails_DblClick(Cancel As Integer)

Dim rstitem As DAO.Recordset
Dim stritemID As String

Set rstitem = dbase.OpenRecordset("tblloan", dbOpenDynaset)

stritemID = hireDetails.Value

rstitem.FindFirst ("[itemid] ='" & stritemID & "'")


txtitemdescription.Value = stritemID

End Sub

This brings up detail within itemdescription textbox, but not the right part of the record. the totalcost appears within there. any ideas?
 
Yes, I have two ideas...

(1) Create a form and set it to datasheet mode with your list box recordsource. Then, set that form as a subform on the form with which you want to edit records. Plus, you can add 'Edit this Now' and 'Save Now' buttons, etc etc.

(2) Your list box when clicked should return the record you want to edit/modify. In the after update event of the list box, open a recordset based on the recordsetclone of the form. Use the recordset's "findfirst" option and navigate to your selected record from the listbox. Then, set the form's bookmark to the recordset's bookmark and voila, you can edit the record you selected.

Hope that helps,
Gary
gwinn7
 
i like the sound of the second one, but what i would like is when the item is double clicked for it to appear on the orderline above. the code whoch i have posted above, would that need to be pasted in to the after update?
 
Yes, put it in the after update, but don't re-use that code there.

Try this concept first...

Dim rs as DAO.Recordset

On error goto handler:

set rs = me.recordsetclone
rs.findfirst "[myvalue] = " & me.lstitem
if not rs.nomatch then
me.bookmark = rs.bookmark
end if

This is the way I know how to do it. If you are using ADO, then it may be different.

Gary
gwinn7
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top