Deleting a row from temp table - temp-tables

I have two grids and on a button click items move from grid 1 to grid 2. Another button removes selected items from grid 2.
The row is deleted from the screen by using:
THIS-OBJECT:ultraGrid2:ActiveRow:Delete().
However then this is saved and repoened this row still appears as it was not been removed from the temp table. The temp-table is called selectedFormula. I've tried:
DELETE FROM selectedFormula WHERE ultraGrid2 = ultraGrid2:ActiveRow.
However i get the error message "Unable to understand after "ultraGrid2 = ultraGrid2".". Does anyone one have any ideas how to remove a item from a temp-table in Progress using ABL?
Any help will be appreciated.

You will need to get the unique key from the active row in the UltraGrid2. Using that key, you find the record in the temp-table and you delete it like this.
FIND selectedFormula
WHERE selectedFormula.[key field] = [key from UltraGrid2]
NO-ERROR.
IF AVAIL selectedFormula THEN
DELETE selectedFormula.
Note: Key can be many fields, depends on your table temp-table definition and data.

Related

Tkinter treeview text not visible until client restart

I have a program written in python 3.5 which scans a directory and stores the info in a SQLITE3 db. This info can be displayed in a ttk.treeview in the client.
The 2 main functions are 1) "scan" which adds the information to the db and 2) viewFiles which is below (it just grabs data from the db and displays it in the treeview).
During the scan function, a second tkinter window is opened and displays information on whats been scanned. If I try to use the viewFiles fucntion without a restart, the data displayed is invisible but I know the data is there because I can copy paste it into a text document). If I restart the client, the text is displayed correctly after pressing the button linked to the viewFiles function.
I think it must be something to do with the the focus shift thanks to this 2nd window opening during the scan process but I'm not sure and can't find any similar case to learn from.
def viewFiles(self):
global dataTreeView
results = []
foldersContentsToView = yieldFoldersToView()
for dpath in foldersContentsToView:
sqlstring= "SELECT * FROM DBDATA WHERE directorypath=:dpath"
values = {"dpath": dpath}
[results.append(i) for i in databaseFunctions.getDBobject().returnSelectQueryResults(sqlstring, values)]
for e in results:
dataTreeView.insert('', 'end', values=list(e))
Does anyone have any ideas?
The issue was that the columns were being set up in the moment the treeview was created by querying the fields in the database. However before the first scan, there were no records in the db and so the columns were not being configured properly until a restart, after which data existed and could be queried on treeview creation.
To fix the issue, I moved the column configure data to the viewFiles function like so:
def viewFiles(self):
global dataTreeView
audioDataTree['columns'] = returnListTableFields()
#Configure Columns
for column in listofdbtablefields():
dataTree.column(column,width=len(column)*10)
dataTree.heading(column, text=column)
dataTree.column(column, anchor='center')
#Hide First Column (TreeLabel)
dataTree.column('#0',width=0)
results = []
foldersContentsToView = yieldFoldersToView()
for dpath in foldersContentsToView:
sqlstring= "SELECT * FROM DBDATA WHERE directorypath=:dpath"
values = {"dpath": dpath}
[results.append(i) for i in databaseFunctions.getDBobject().returnSelectQueryResults(sqlstring, values)]
for e in results:
dataTreeView.insert('', 'end', values=list(e))

How can I delete an object which is the subject of a loop?

The problem I have is that the user is copying from one content control and pasting it into another accidentally. When extracting the data from this form, it then picks up that extra CC and therefore the value twice over.
When pulling the data I'm trying to see if a CC has a ParentCC and then delete it, but I keep getting
Run time error 5825: Object has been deleted.
I can understand why but I'm unsure as to how get around it, nothing I've searched seems to work.
'With Word document Statement precedes this
For Each CCtrl In .ContentControls
CCtrlText = CCtrl.Range.Text
If Not CCtrl.ParentContentControl Is Nothing Then
CCtrl.ParentContentControl.Range.Text = CCtrlText
CCtrl.Delete
End If
Next
How can I remove this content control which is duplicated inside the other and retain the input information?
So after some messing around and looking into how the local variables properties changed as a stepped through the code I have found that the line:
CCtrl.ParentContentControl.Range.Text = CCtrlText
Was in effect replacing the Content Control (CC) in it's ParentCC range property with the input text, and therefore deleting the duplicated CC.
CCtrl.Delete was trying to delete an object that had already been deleted and that swhy it was throwing an error.
I think with a foreach loop you can't alter the contents of the list/array without impacting the function of the loop. If you instead use the indexers, it should allow you to alter the collection, since you are not impacting the loop (number to number):
Dim i As Integer
Dim c As ContentControl
For i = 1 To d.ContentControls.Count
Set c = d.ContentControls(i)
c.Delete
Next i

Reference SlicerCache by name, not number

I have some code referencing Slicers:
For Each item In wb.SlicerCaches("Segment").SlicerItems
If item.Selected = True Then
If Len(sSegment) > 0 Then sSegment = sSegment & "|"
sSegment = sSegment & item.Caption
End If
Next item
but I get Invalid procedure call or argument. I've seen many examples referencing them by name, but can't get it to work. If I use (1), (3) etc and then add a slicer, it messes up the order, so the code is mucked up.
How can I reference them by name, my end goal is to iterate through selected items.
You may need to reference the slicercache by adding Slicer_ in front of it.
For example, I added an Authors slicer to a table containing information about books and I could reference it by using this code:
Debug.Print ActiveWorkbook.SlicerCaches("Slicer_Author").Slicers("Author").Caption
The reason I knew to add Slicer_ is because I right clicked the slicer and then selected Slicer Settings... and saw this:
And that seems to reference the slicer fine. It was really dumb luck that I happened to see that and thought to try it.
Try:
For Each item In wb.SlicerCaches.Item("Segment").SlicerItems

How to perform a custom search using a button formula

I would like to create a button to search my mail's Inbox view for emails which contain a unique string found in the subject field of the selected document. For this, I have created the following button formula. This correctly retrieves the unique string but the search itself does not work.
SearchStringLeftPart := #Left( Subject; "] [");
SearchString := #RightBack( SearchStringLeftPart; "[");
#SetViewInfo([SetViewFilter];SearchString;Subject;0;0)
Please can someone advise if #SetViewInfo can be used for this purpose & if so what is wrong with the formula. Otherwise how else can I achieve the task using a button formula?
Unfortunately, you can't accomplish that with #SetViewInfo.
But, in combination with a short agent you can show only those documents in view which have current document's unique Subject substring in their Subject field.
Create a formula agent "SelectSubjectSearch" with
target "All documents in view"
option "Selects documents in view"
formula
SELECT #Contains(#LowerCase(Subject); #LowerCase(#Environment("SubjectSearch")))
Create a formula button which
writes the search string into environment variable "SubjectSearch"
selects the option "View / Show / Selected Only" in menu
calls the agent "SelectSubjectSearch"
Button code:
SearchStringLeftPart := #Left( Subject; "] [");
SearchString := #RightBack( SearchStringLeftPart; "[");
#SetEnvironment("SubjectSearch"; SearchString);
#Command([ViewShowOnlySelected]);
#Command([ViewShowOnlyUnread]);
#Command([ViewShowOnlyUnread]);
#Command([ViewShowOnlySelected]);
#Command([RunAgent]; "SelectSubjectSearch")
The tricky part is the "View / Show / Selected Only" selection. As [ViewShowOnlySelected] just toggles between "Select Only" and not "Select Only" and you don't know which status currently is set we have to call a double [ViewShowOnlyUnread] which resets [ViewShowOnlySelected] to not "Select Only". The first [ViewShowOnlySelected] sets the information bar to "You are seeing: the item you selected" and the second [ViewShowOnlySelected] does set for sure "Select Only".
Is the subject exposed in the first (sorted) column of the view?
IIRC, SetViewInfo only filter the view on the first column, which alse must be sorted.
Update: Did not refresh the page after I got back from lunch, so did not see that there already was a correct answer.
Create a search view with first column sorted by subject and use view.getAllDocumentsByKey(...)to get the documenta you search

ColumnCount in DataGridView remains 0 after assigning data source

I am having trouble with the following simple code
BindingList<Car> tempList = new BindingList<Car>();
BindingSource bindingSource = new BindingSource();
bindingSource.DataSource = tempList;
dgTempView.DataSource = bindingSource;
Here, dgTempView is a data grid view
After the above lines execute, the column count in the datagrid view remains 0. And when I try adding a Car instance in tempList, I get an error saying that 'no row can be added to a datagridview control that does not have columns' . I am not able to understand what am I missing here
Found my mistake. The members of the Class Car were public instance variables and not properties. The moment I changed them to Auto Properties it worked :)

Resources