Skip to main content

Dialog Box (How to connect checkbox with functions

Hi Brian,
 
I hope you are doing well.
I have created a dialog to import some tables into a project.
Attached is my codes. My problem is I could not find how to connect each function (like GL_BS, Gl_EXP,...) to the checkboxes I have created.
I just want to import selected tables into a project by using this checkbox.
 
thanks,

Brian Element Fri, 03/04/2022 - 07:10

Wow, you were so close.  Your main problem was for the Select Case Action% you had your code under Case 1.  Case 1 is when you first start-up the dialog so it only gets run once on the initial start-up.  What you wanted was Case 2 as this is run when something changes in an dialog, such as clicking on a checkbox.  Here is your updated code.  Also watch your indenting.  Several places you didn't indent, IDEAScript doesn't care but it makes the code harder to understand if you don't indent consistently.  It is a good habit to get into.

 


Option Explicit
Dim bExitScript As Boolean
Dim Importers(8) As Integer

Sub main
	Dim i As Integer
	Call menu()
	If Not bExitScript Then
		If Importers(0) Then
			Call GL_BS
		End If
		If Importers(1) Then
			Call GL_EXP
		End If
		If Importers(2) Then
			Call GL_REV
		End If
		If Importers(3) Then
			Call PAY_BS
		End If
		If Importers(4) Then
			Call PAY_EXP
		End If
		If Importers(5) Then
			Call PAY_REV
		End If
		If Importers(6) Then
			Call AP_BS
		End If
		If Importers(7) Then
			Call AP_EXP
		End If
		If Importers(8) Then
			Call AP_REV
		End If

	
	Else
		MsgBox "Importing Cancelled"
	End If
	Client.CloseAll
	client.refreshFileExplorer
	
End Sub

Function menu()
	Dim dlg As DialogDemo
	Dim button As Integer
	button = Dialog(dlg)
	If button = 0 Then bExitScript = True 
End Function

Function displayIt (ControlID$, Action%, SuppValue%)
	Dim bExitMenu As Boolean
	Dim chkValue As Integer
	Dim i As Integer
	Dim btable As Boolean
	
	Select Case Action%
	
		Case 2
			Select Case ControlID$
					
					Case "selectall" 
						If DlgValue("selectall") Then
							chkValue = 1
						Else
							chkValue = 0
						End If
						
						For i = 1 To 9
							DlgValue("CheckBox" & i), chkValue
						Next i
			
					Case "OkButton1"
						For i=0 To 8
							Importers(i) = DlgValue("CheckBox" & (i+1))
							If  DlgValue("CheckBox" & (i+1)) Then 
								btable = True
							End If
	
						Next i
						
						If Not btable Then
							MsgBox "Please select at least one table"
						
						Else
							bExitMenu = True
						End If
	
					Case "CancelButton1"
						bExitMenu = True
						bExitScript = True
			End Select
	End Select
	
	If bExitMenu Then 
	
		displayIt = 0
	Else
		displayIt = 1
	End If
		
End Function