How to add items to Combobox in Dialog
Forums
Hi,
Can anybody tell me the syntax to add items to a Combo box placed in Idea Scripting Dialog control?
Thanks,
Shafeer
Hello Shafeer,
Hello Shafeer,
You can use this code to populate the field names into a Combo box. fieldlist$() is the array that holds the field names in the Combo box. This section first gets the IDEA file and then adds each field to the array.
Dim filebar As Object
Dim filename As String
Dim source As Object
Dim table As Object
Dim rst As Object
Dim field As Object
Dim fields As Integer
Set filebar=CreateObject("ideaex.fileexplorer")
filebar.displaydialog
filename=filebar.selectedfile
If filename <> "" Then
Set source=client.opendatabase(filename)
Set table=source.tabledef
Set rst =source.recordset
fields=table.count
ReDim fieldlist$(fields)
j=1
For i=1 To fields
Set field=table.getfieldat(i)
fieldlist$(i)=field.name
Next i
End If
Hi Brian, nice Page you have
Hi Brian, nice Page you have here :)
My problem fits into this topic at best, I think.
I've written a few larger scripts with variables, they are mostly working as they should.
Now I want to make them more user friendly by using dropdowns to fill in the variables.
Ist it possible that the dropdown selection is filled in to my variables automatically?
I have only basic knowlegde of Scripting, everything I have is a copy out of the history of IDEA extended with the variables...I give you a short example how my scripts are build:
'Global Variables
Dim VAmount as String
Sub Variable_define
VAmount = "" <-- there I fill in the field names manual
'Open Routines
Call entries_without_amount
call other routines...
end sub
Sub entries_without_amount
Set db = Client.CurrentDatabase()
Set task = db.Extraction
task.IncludeAllFields
dbName = "Entries without amount.IMD"
eqn = "" & VAmount & "=0"
task.AddExtraction dbName, "", eqn
task.PerformTask 1, db.Count
Set task = Nothing
Set db = Nothing
end Sub
Thanks for your help,
Norbert
Edit: insert paragraphs
Hello Norbit and welcome to
Hello Norbit and welcome to the site.
I am not sure what you mean by filling the drop-down automatically, you have to always have some code in the background that populates the drop-down but the information can change depending on the file you are using. Drop-downs are great for selecting fields as you can populate the drop-down with the field names and you could filter out the fields to only display the character fields, numeric, etc.
Also you could populate the drop downs with any other type of text information that is generated in your script.
Now drop-downs have their limitations in that you can only select one item from them, unfortunately IDEAScript dosn't have a built in function to select multiple items, in those instance you can add some code to create a user created list box like in this example.
In your example it seems that you probably want to add multiple fields, in this case a drop down wouldn't be the best but using a list box as in the above example would be what you need.
Let me know if this is what you are looking for and I will put together an example script for you.
Brian
By "filling the drop-down
By "filling the drop-down automatically" I mean that in the dialog there are seperate drop-downs for every field that is needed by the script.
There is one drop-down for the amount, one for the entry date, one for user... and so on - every variable has its own drop-down and so you don't need to do select multiple Items at once.
Every drop-down should fill a variable within the script so that the user can use a dialoge instead of the script editor to fill in the fields.
I have further settings that are made inside the script, set dates in variables like the beginn of a fiscal year - but I think taht could be solved with a text field (the easiest way) where the user enter the date in a defined format (YYYYMMDD)
The script is unfortunately written with german term for the variables and comments, I could show you some parts if you want to.
There are 17 variables to filled in with field names from the database, other 10 variables for text search, 2 variables to control the parts of the script (one for routines and graphics, the other controls the special parts for the accounting system like SAP), 4 variables for numbers (like days between entry date and booking date) and 3 variables for dates (like begin and end of the fiscal year)
I used to save the script with the filled in variables if I need to rerun it with new data from the clients...
hopefully that is not too much information - to adress my problems in english is far more difficult than I thought to..
Thanks,
Norbert
Norbert, thanks for the info.
Norbert, thanks for the info. I will put something together for you. Maybe you could list the variables that you want to populate, if you expect the variable to be character, numeric, date, etc and if it will come from a drop-down or a text box. That way I can try and relate the example directly with your variable.
Demo of creating a combobox
Hello and welcome to the site.
Below is a simple example of using a combobox. You would first create a dialog with a combo box. In the properties for the ComboBox you need to add a variable for the Attached List, you can add something like list1$(), the $ means that the variable is of type string and the () defines it as an array. You don't have to Dim as the scripting editor will take care of it by placing Dim list1$() as the first line (this line is hidden unless you open it in an editor such as notepad).
You would then ReDim the list1$ variable to indicate how many items the array will include, you then add the items to your array and call the dialog, IDEA will automatically add this array to the dialog because of the name. There is another way to do this which is a bit more complicated, let me know if this is good enough or if you wish to learn the more "complicated" way. Also I have attached the script of this demo.