By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,407 Members | 2,842 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,407 IT Pros & Developers. It's quick & easy.

editing items within a listbox

P: 49
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?
Jan 29 '08 #1
Share this Question
Share on Google+
6 Replies


convexcube
P: 47
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?
Hi Goldstar,

I think the reason you a getting the wrong field returned is that you are telling the text box "txtitemdescription" to equal "stritemID" which was earlier defined as the value of the list box "hireDetails". So although you have created a recordset and selected the record in the recordset that is selected in the list box, you have told the text box to display only what is selected in the list box, meaning that the recordset has been bypassed. This could be OK, except that the value of the list box is equal to the value of the selected rows first column, which in this case must be the total cost. If you want to go this way, what you want in the first column is the itemid (you can hide it by making the column width = 0 if you want), or reference the specific column that the itemid is in by "hireDetails.Column(the number of the column that the itemid is in)".

Or to use the recordset you have defined, change "txtitemdescription.Value = stritemID" to "txtitemdescription.Value = rstitem!itemid"

As far as I can see this is the problem so I hope this advice helps, if you need some more help let me know but I may need a little more information about the table structure and the code used to add the record to the list box. I have done this before in a different way so if you want to try that too let me know.

Kind Regards,
Ken Farrawell
Jan 29 '08 #2

P: 49
Hi Goldstar,

I think the reason you a getting the wrong field returned is that you are telling the text box "txtitemdescription" to equal "stritemID" which was earlier defined as the value of the list box "hireDetails". So although you have created a recordset and selected the record in the recordset that is selected in the list box, you have told the text box to display only what is selected in the list box, meaning that the recordset has been bypassed. This could be OK, except that the value of the list box is equal to the value of the selected rows first column, which in this case must be the total cost. If you want to go this way, what you want in the first column is the itemid (you can hide it by making the column width = 0 if you want), or reference the specific column that the itemid is in by "hireDetails.Column(the number of the column that the itemid is in)".

Or to use the recordset you have defined, change "txtitemdescription.Value = stritemID" to "txtitemdescription.Value = rstitem!itemid"

As far as I can see this is the problem so I hope this advice helps, if you need some more help let me know but I may need a little more information about the table structure and the code used to add the record to the list box. I have done this before in a different way so if you want to try that too let me know.

Kind Regards,
Ken Farrawell
Currently in my listbox i have

ItemID, Hirevehicle, totalcost

but with that code i mentioned above it displays the total cost within the other fields and not the relevant detail.

cboitemID.Value = stritemID!itemid
txtclothingtype.Value = stritemID!Hirevehicle

it know displays data within these fields, but whatever record i double click it displays the first record in the listbox and not any other one.

hope you could understand this!!!
Jan 29 '08 #3

convexcube
P: 47
Currently in my listbox i have

ItemID, Hirevehicle, totalcost

but with that code i mentioned above it displays the total cost within the other fields and not the relevant detail.

cboitemID.Value = stritemID!itemid
txtclothingtype.Value = stritemID!Hirevehicle

it know displays data within these fields, but whatever record i double click it displays the first record in the listbox and not any other one.

hope you could understand this!!!
Hi Goldstar,

I think I might need to see the whole database to get a handle on how you want to achieve this. Is it big? Would it be possible to send it to me? Let me know, and if you can I will PM you my email address.

Kind Regards,
Ken Farrawell.
Jan 29 '08 #4

P: 49
Hi Goldstar,

I think I might need to see the whole database to get a handle on how you want to achieve this. Is it big? Would it be possible to send it to me? Let me know, and if you can I will PM you my email address.

Kind Regards,
Ken Farrawell.
I wish i could, but the regulations at college would not allow this.... sorry
thanks for the offer it is much appreciated.
Jan 29 '08 #5

convexcube
P: 47
I wish i could, but the regulations at college would not allow this.... sorry
thanks for the offer it is much appreciated.
No problems, I'm working on an example of how this would work. I will send it to you when done if thats OK. Let me know.

Kind Regards,
Ken Farrawell
Jan 29 '08 #6

convexcube
P: 47
Hi Goldstar,

I have a working example for you. PM me with your email address and I'll send it to you

Kind Regards,
Ken Farrawell
Jan 30 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.