I have this code to populate the list box from information on the parent form:
Code: Select all
Sub PopulatedlgRemoveJobContactListBox()
DataSource = ThisComponent.Parent.DataSource.GetConnection("","")
JobID = ThisComponent.DrawPage.Forms.GetByName("MainForm").GetByName("txtJobID").text
SQLResult=createUnoService("com.sun.star.sdb.RowSet")
SQLQuery = "Select ""JobContacts"".*, ""Contacts"".""ContactName"" AS cntName FROM ""JobContacts"", ""Contacts"" WHERE ""JobID"" = " & JobID & " AND ""Contacts"".""ContactID"" = ""JobContacts"".""ContactID"""
SQLResult.activeConnection = DataSource
SQLResult.Command = SQLQuery
SQLResult.execute
exitOK=com.sun.star.ui.dialogs.ExecutableDialogResults.OK
DialogLibraries.LoadLibrary("Standard")
Dialog=CreateUnoDialog(DialogLibraries.Standard.dlgRemoveJobContact)
DialogField=Dialog.GetControl("lstContacts")
While SQLResult.next
ListBoxItem = SQLResult.getString(4)
DialogField.additem(ListBoxItem, DialogField.ItemCount)
Wend
If Dialog.Execute=exitOK Then
CurrentItemName=Dialog.SelectedItem
End If
End Sub
I'm tried to do another sub
Code: Select all
Sub RemoveContact()
DataSource = ThisComponent.Parent.DataSource.GetConnection("","")
SQLDelete = "DELETE FROM ""JobContacts"" WHERE ""JobID"" = " & JobID & " AND ""ContactID"" = " & Dialog.SelectedItem(3)
SQLResult.activeConnection = DataSource
SQLResult.Command = SQLDelete
SQLResult.execute
exitOK=com.sun.star.ui.dialogs.ExecutableDialogResults.OK
End Sub
I've added an attachment of the Dialog box, not that it will help, but just in case.
I am new to Base and Macros. Any help is appreciated. Thank you.