Skip to main content

Dropdown menu with fields

I want to create a dropdown menu with the fieldnames. In my test script (Test fields to dropdown menu works) it works but in my project script (RB Temp 1) it doesn't work. What do i wrong? I want to understand how the basic code is to populate a list and show it to the user.
 

Brian Element Thu, 08/23/2018 - 10:44

Hi Robert,

The reason it worked in the first one is because you are closing your dialog and then reopening it so that is how the drop-downs are getting populated.  In the second example you are using the DisplayIt function so you need to see another function to attach the list to the array, just naming it the same does not work here. What you need is to use the DlgListBoxArray, this allows you to attach an array to a dropdown through the dialog function.  So after the Call GetFieldList1() add the following lines and hopefully that will get it working:

DlgListBoxArray "DropListBox1", List1$()
DlgListBoxArray "DropListBox2", List1$()
DlgListBoxArray "DropListBox3", List1$()
DlgListBoxArray "DropListBox4", List1$()

For each of the drop lists we are adding the array that holds the list of field names.

Brian

Robert van den… Thu, 08/23/2018 - 11:17

In reply to by Brian Element

funny how one line of codes changes it al. But basicly from the case ID/action you can call functions to run. Do you prefer to get as little code in the displayIt function and define it as seperate functions? And is there a way to make a function more flexibel to use it multiply times but with different variables? Thanks again for your time.   

Brian Element Thu, 08/23/2018 - 12:24

For the change above you can probably do something like this:

For i = 1 to 4

     DlgListBoxArray "DropListBox" & i, list1$()

next i

Sometimes you just end up having lots of line of code to update the items.

Robert van den… Fri, 08/24/2018 - 05:59

Hi, the finale step in my script for the user is to select the fields from the different tables. I used the script code which you provided a few days ago with a dialog box with two lists with the field names and buttons to change fields from one list to the other. At the moment there are two things i don't understand: 1) what is the reason for using a templistbox variable? 2) After the user selected the fields to use and press ok i there a way to show the selected fields by the user in messagebox or a static text? And 3) When i repress the button to select fields agian it didn't rememberd what the user did before that, is there a way so that previous actions in selecting fields are rememberd?

Robert van den… Fri, 08/24/2018 - 06:35

In reply to by Robert van den…

I tried to do a direct extraction and add the fields selected in the list to the direct extraction using the following code:
For i = 0 To UBound(tempListBox1AB$)task.AddSFieldToInc tempListBox1AB$(i)Next i
Instead of: 'task.IncludeAllFields
but i got error: object does not support this property or method. Can you help me, where i'am thinking wrong.
 

Brian Element Fri, 08/24/2018 - 09:14

In reply to by Robert van den…

1) Hi Robert, the templistbox variable is to hold the array for each of the list boxes as they are constantly changing.  The tempListSelect varaible holds the users selection.

2) Sure, just create a message box after the user has clicked ok.  The loop through the items and display the message, probably something like:

msg = "You have selected the following fields:" & chr(10) & chr(13)

for i = 0 to ubound(templistbox2$)

     msg = msg & templistbox2$(i) & chr(10) & chr(13)

next i

msgbox msg

3) For three you would have to compare what is in the first templistbox1$ and remove those that are in templistbox2$.  If I have some time I will see if I can come up with the code.

Robert van den… Fri, 08/24/2018 - 11:00

Hi, i added on line 419 a check to disable a button when the list isn't empty (the user selected the fields). But i get an stack overflow error. Does this means there are to many conditions or do i need to place it some where else?

Brian Element Fri, 08/24/2018 - 12:30

In reply to by Robert van den…

Hi Robert, this might be a harder one to track down.  Do you have a copy of your script that has been indedented?  It is hard to read when the code is all lined up.