Hi All, I am looking to update a Listbox in a form based on another Listbox. There are many examples of how to do this using various different methods. I have had help previously for the same problem. However when i have tried to apply this to the new version of my database things are not good.
My current requirement is in the ECN-RFQ form that the customer purchasing Listbox is restricted to only showing persons from the customer listed in the previous customer Listbox.
I have tried for many hours with two of the tried and tested options, 1 using a refresh button and 2 using a macro.
both have failed miserably.
This has me asking a couple of questions.
-
How to copy macro from one database to another. I have tried using the organise macros option. I can for example see my previous database with a “refresh” macro and I can see my new database underneath but cannot see a way to copy the macro. I was able to select and drag the macro to a new database but not able to copy it. I wanted to copy it and try to update the various commands to work on a different database and form.
-
The following macro was kindly given to me by Sir Ratslinger, this worked on my previous database so I wanted to adapt it for my new effort. I know there are other stuff running in the database Listboxes involved but can the following macro easily be used in my new database by simply using macro organiser, new, pasting in and modifying the various references to suit?
The macro is this,
Sub CustChange
oForm1 = ThisComponent.Drawpage.Forms.getByName(“MainForm”)
oField = oForm1.getByName(“txtCustomer”)
sSelectedValue = oField.SelectedValue
sSql = “SELECT DISTINCT ““Item”” FROM ““PartNumber”” WHERE ““Customer”” = '” & sSelectedValue & “’ ORDER BY ““Item”” ASC”
oField = oForm1.getByName(“txtReplaces”)
oField.listsource = array(sSql)
oField.refresh()
End Sub
I dont think this can be adapted easily as the database basic structure is different.
-
Do i have to have certain libraries or addons running for some macros to work, i think the obvious answer is yes but for the above macro do i need anything special running. The above macro makes sense to me and i can see how the sSql line works. However not well enough for me to use in the attached database on the ECN-RFQ form.
-
Could someone be so kind as to format the above macro to work with the ECN-RFQ form to enable only the relevant purchasers to show according to their company (customer) name? I can then use this to study how to do the same on other forms as I am sure I will use this kind of Listbox again on other forms.
Many thanks in advance.
Regards MaxProject Tracking Test V1.09.odb