Skip to main content

Can DropListBox could automated tagged ?

Hi Brian,
If my dialog have 6 droplistbox call DropListBox1 to DropListBox6, and those droplistbox all used same attached list array.
Have any possible, I add a button call "Auto Mapping", and pre-defind if DropListBox1 = SO_NUM, DropListBox2 = SO_LINE_NUM, DropListBox3 = SO_CUSTOMER, DropListBox4 = SO_ITEM, DropListBox5 = SO_UNIT_PRICE, DropListBox6 = SO_QTY, when I click the AuotMapping button the system can automated tagged as picture 2 ?
 
Regards,
Derek

Brian Element Wed, 07/11/2018 - 07:22

Hi Derek,

Yes this can be done but it means having to close and reopen the dialog.  Here you can see my example:

And when you select the Auto Mapping you get this:

How this is done is that I have a loop to keep the dialog open while the user has selected the Auto Mapping button.  If the button has been selected I select the item by using the dlg.DropListBox1 = 2, the 2 would be the third item in the array (arrays start with a value of 0) and then display the dialog again.

Here is the code that hopefully you can see what I did.  I have also attached it so you will have the items for the menu.  Let me know if you have any questions or if something doesn't make sense.

 


Option Explicit
Dim bExitMenu As Boolean

Sub Main
	Dim dlg As NewDialog
	Dim button As Integer
	
	'redim and populate the list array
	ReDim listbox1$(4)
	listbox1(0) = "Select"
	listbox1(1) = "Banana"
	listbox1(2) = "Apple"
	listbox1(3) = "Pear"
	listbox1(4) = "Plum"
	button = 0
	'keep the dialog open if the Auto Mapping button has been selected.
	Do While Not bExitMenu
		If button = 1 Then
			dlg.DropListBox1 = 2 'set the default value for the array
		End If
		button = Dialog(dlg)
		'The Auto Mapping button is the first button so it will return 1
		'this will change depending on the order of the buttons added
		'to the dialog
		If button <> 1 Then bExitMenu = True 
	Loop
End Sub

Derek Wed, 07/11/2018 - 08:14

Hi Brian,
Thanks. Based on your description and code, I know how to modify and write my script.
Br,
Derek