Ask Your Question

Cut and paste macro for listbox contents not working

asked 2018-04-05 17:26:46 +0100

MaaX gravatar image

updated 2018-04-05 17:27:28 +0100

So i have reviewed what i previously had and changed things around a little. I have progressed a little by referring back to previous help Etc. So uploaded is same database V1.13 Here I now have the form ECNListByCustomers added. So when i open the form without touching the customer listbox i have a full list of ECN data in the ECN List listbox. After pressing refresh this updates the subform in accordance with the chosen ECN. I can then add PartNumber and Description. However I would like to filter the ECN List listbox depending on the Customer chosen. I have tried to edit the previous macro but the best i can achieve so far is for the ECN List listbox to clear. I feel I am very close but no matter how much tinkering i do with the macro i cant manage to get it to work. I did add a second refresh box in case it was a refresh problem but no joy so removed it for now. I would also like to have the current refresh box removed but happy to stay with it until immediate issue is resolvedC:\fakepath\Project Tracking Test V1.13.odb

edit retag flag offensive close merge delete


Previous version 1.09 was for question

Jim K gravatar imageJim K ( 2018-04-05 20:19:41 +0100 )edit

+1 for a fairly good question. Two suggestions for improvement: Add a link to the previous question (which I did for you), and add paragraph breaks to make it easier to read.

Jim K gravatar imageJim K ( 2018-04-05 20:24:50 +0100 )edit

1 Answer

Sort by » oldest newest most voted

answered 2018-04-05 20:43:44 +0100

Jim K gravatar image

updated 2018-04-05 20:47:36 +0100

The query in CustChange2 is looking in the wrong table. Also, it should grab two fields: one for the ECN number to display and one for the underlying ID. Here is the corrected query.

sSql = "SELECT ""ECN-RFQ Reference"", ""ECN-RFQID"" FROM ""ECN-RFQ"""&_
    " WHERE ""CustomerID"" = '" & sSelectedValue & "' ORDER BY ""ECN-RFQID"" ASC"
edit flag offensive delete link more



There is also another problem with the sample you posted. If you do select anything in Customer list box you will get an error:

    BASIC runtime error.
Property or method not found: SelectedValue.

This is because there are two controls on the form with the same name: txtCustomer

One is the label control for the list box and the other is the listbox itself. Change the name for the label control to something else.

Ratslinger gravatar imageRatslinger ( 2018-04-06 03:21:37 +0100 )edit

Thanks guys, the duplicate name was careless. I am going to post another question regarding naming of fields. I will update the names and see if I can get it to work without looking at the above solution as I do like to be able to make a little progress. I will come back with my progress. Thanks guys.

MaaX gravatar imageMaaX ( 2018-04-06 08:47:39 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-04-05 17:26:46 +0100

Seen: 55 times

Last updated: Apr 05 '18