How can I display data to a textbox from data grid view in Archestra? - wonderware

I want to display the data in textbox from the datagrid view by selecting different rows in the Archestra software.Is there a syntax so that i can display the data?
currently I am using the syntax
textbox1.text =selectedrows.item(0)
I need a syntax so that I can display the selected row in a text box.
I need to do this in wonderware Archestra software.

It's not possible to retrieve the entire row into a string with one command. You would need to read the currently selected row and then each column in turn. You could then concatenate it into a string.
Small example:
DIM x;
x = #Grid.GetRowNumber();
Grid\column1 = #Grid.GetRowColumnValue( x, 0);
Grid\column2 = #Grid.GetRowColumnValue( x, 1);
....
Grid\selectedRow = Grid\column1 + Grid\column2 + ...

Related

Coding index match to search multiple columns

I need to search for a number in multiple columns, then return the information in another cell. Here is a sample table:
I would like to keep the names on the left and the meets on the top. Additional names and meets will be added at a later time.
On a separate tab, I use the function:
=SMALL('100M'!B2:D5,1)
To locate the smallest number in the table. I now need to search the table for the result of the function above and return the name of the person. I know the index/match:
=index('100M'!$A$2:$D$5,match($B$2,'100M'!$D$2:$D$5,0),1)
This will work if I specify the exact column. I need to search through every column to match the Small number, then return the individuals name.
Create a user defined function
Function GetMinName() As String
Dim dataRange As Range
Dim minValue As Double
Dim minValueCell As Range
' Define the data range
Set dataRange = Worksheets("Sheet1").Range("B2:D5")
' Find the minimum value in the data range
minValue = WorksheetFunction.min(dataRange)
' Find the first cell containing minimum value
Set minValueCell = dataRange.Find(minValue, LookIn:=xlValues)
' Return the name in col 1 of the row containing the min value.
GetMinName = Worksheets("Sheet1").Cells(minValueCell.Row, 1)
End Function
This is the formula you put in the cell on the other sheet.
=GetMinName()

How to use Split array of a single cell for data validation dropdown?

I am trying to create data validation dropdown from a single cell which has all , separated values and I am splitting them using SPLIT(K4,","). But when I apply the formula drop-down just goes away. Here is how it looks:
And here is where I have applied validation:
It just happens and I can't see any drop-down here. Even validation doesn't work as I type a value from given values, it still identifies it as invalid:
Here it says that it is actually not possible, but otherwise, my data column will grow very big, that's why I wanted to keep it in a single cell.
Method to reproduce: Just make a copy of this sheet and experiment on your own whatever you want it to be like:
It is not possible to do this from the sheets editor, but you could use Google Apps Script to accomplish this:
Open the script editor by selecting Tools > Script editor.
Copy and run this function:
function createDataValidation() {
const sheet = SpreadsheetApp.getActiveSheet();
const values = sheet.getRange("A1").getValue().split(","); // Get array with values from A1
const rule = SpreadsheetApp.newDataValidation().requireValueInList(values); // Create DV
sheet.getRange("F8").setDataValidation(rule); // Set DV to F8
}
Reference:
Class DataValidationBuilder

How to format currency columns in Axlsx?

I am using ruby Axlsx gem for writing my clients accounts data in xlsx. Now I am appending " Dr" string to all debit amounts which is making amount as a string e.g. "1000 Dr". I want to append " Dr" but the amount should still be an integer and excel should give sum at bottom when column is selected.
What I am doing, notice that excel shows sum = 0 in bottom-right even on selecting :-
What I am doing, notice that cell remains a string on selecting (880 Dr should become 880.00 on selecting the cell):-
What I want to do, excel should show sum of selected colums as shown by excel in bottom-right sum=1957.00 Dr:-
What I want to do, the cell should be converted to number when double clicked (1341.00 Dr has become 1341 on selecting)but Dr should be visible on unselecting again:-
I solved this by using custom format_code
custom_format = sheet.styles.add_style(:format_code => "#.00 "Dr"")

Automatically fill out textbox doble clicking on an item in a listbox

Another beginners question, but this time about MS Access Controls.
I have a form where I have a list box full with many items.
What I need to do is when I double click on one of this item stored in the list box should all the textbox filled with an item stored on a different field from the same row where from my table.
I checked many tutorials already but didn't found a good solution.
Thanks for any help!
EDIT:
I have a table with several fields. The list box have the items from the first field(ID). The rest of the fields(Tile, Delivery Date, etc...) represented by text boxes in my form.
When I double Click on one item from the list box will populate the text boxes.
If I select the 5th item from my list box which represents the 5th row from my table every text box should have their item from the same row from the fields represented in the table.
I only want to edit the data stored in the table with this form.
Ok I finally get a solution for this one.
I using the DLOOKUP to get the data pulled to my form after the double-click event.
Dim ctrloop
For Each ctrloop In Me.lbReportID.ItemsSelected
strReportID = Me.lbReportID.ItemData(ctrloop)
Next ctrloop
Me.txtTitle = DLookup("[Title]", "tblreports", "[ID No] = '" & strReportID & "'")
The loop stores all report ID I have in my table. The DLOOKUP using this as a filter. It's like the WHERE in SQL.
When the program run will fill out my Title textbox looking through the title field in my tblreports table filtered with the strReportID.
It's working similarly like this SQL query which I using in a different textbox:
SELECT tblReports.[ID No]
FROM tblReports
WHERE (((tblReports.WorkPacage) = 'CDS'))
AND (((tblReports.State) <> 'Complete'));

Creating a Macro in google spreadsheet to search and then write text

What I am trying to accomplish is I would like to search for a term in one cell, if that cell has the term write text to another cell. My specific example would be I would like to search for the term 'DSF' in column 4. If I find 'DSF' it would then write 'w' in column 5 & write '1.2' in column 3. This is searched per row.
I do understand the the .setvalue will write the needed text, but I do not understand how to create a search function. Some help would be greatly appreciated.
EDIT
Here is the code I am working with at the moment. I am modifying it from something I found.
function Recalls()
{
var sh = SpreadsheetApp.getActiveSheet();
var data = sh.getDataRange().getValues(); // read all data in the sheet
for(n=0;n<data.length;++n){ // iterate row by row and examine data in column D
if(data[n][3].toString().match('dsf')=='dsf'){ data[n][4] = 'w'}{ data[n][2] = '1.2'};// if column D contains 'dsf' then set value in index [4](E)[2](C)
}
//Logger.log(data)
//sh.getRange(1,1,data.length,data[3].length).setValues(data); // write back to the sheet
}
With the Logger.log(data) not using the // It works properly but it overwrites the sheet, which will not work since I have formulas placed in a lot of the cells. Also, Maybe I did not realize this but Is there a way to do a live update, as in once I enter text into a cell it will research the sheet? Otherwise having to 'run' the macro with not save me much time in the long run.
Try this. It runs when the sheet is edited. It only captures columns C,D,&E into the array and only writes back those columns. That should solve overwriting your formulas. It looks for 'DSF' or 'dsf' in column D (or contains dsf with other text in the same cell either case). Give it a try and let me know if I didn't understand your issue.
function onEdit(){
var sh = SpreadsheetApp.getActiveSheet();
var lr = sh.getLastRow()// get the last row number with data
var data = sh.getRange(2,3,lr,3).getValues(); // get only columns C.D,& E. Starting at row 2 thur the last row
//var data = sh.getDataRange().getValues();// read all data in the sheet
for(n=0;n<data.length-1;++n){ // iterate row by row and examine data in column D
// if(data[n][0].toString().match('dsf')=='dsf'){
if(data[n][1].match(/dfs/i)){ //changed to find either upper or lower case dfs or with other text in string.
data[n][2] = 'w';
data[n][0] = '1.2'};
}
sh.getRange(2,3,data.length,data[3].length).setValues(data); // write back to the sheet only Col C,D,& E
}

Resources