Reordering ADO Recordset columns - delphi

I have a recordset with columns
e.j
ID_PEOPLE
NAME
AGE
And I need to reorder this columns to
ID_PEOPLE
AGE
NAME
This recordset is used to fill an Excel spreadsheet and need to change the recordset column order because reordering in Excel is to slow.
Any idea?

Right click on your Table/Query, select Field Editor.
If there are not fields, press CTRL+F.
Drag by mouse fields changing order as you want.
Or, if you have a Query, you may change select field order: select Field2, Field1 from Table.
Or you may physicaly redesign field order in your table/view/procedure.

Related

Google sheets - select multiple columns for data validation

I'm new on google spreadsheets, and I'm having this little problem:
I want to create a project manager with an external spreadsheet just for customer-info. In my "main-hub" sheet, I have created a dropdown menu on B11 which copys the customer names from the extrenal sheet. That works fine.
Now the problem I am trying to solve: I want to keep the drop-down menu on B11, i dont want to add any new drop down menus. Whenever I select an item from the menu on B11, additional information about the customer should be inserted into different cells in different columns. Example:
| __________ B11 __________ | __________ J11 __________ | __________ K11 __________ |
Selected Name dynamicly inserted data 1 dynamicly inserted data 2
Please keep in mind, I really don't want to add any new drop down menu, I want to keep only this one for the names of the customers.
What you're looking for is "VLOOKUP". This is a Formula where you can define a specific range and select the part you want to display. I've edited your spreadsheet.
=IFERROR(VLOOKUP(A2;'Customers static'!$A$2:$C$5;2;FALSE);"")
IFERROR Value, [value if error]
VLOOKUP Search key, area, index, is sorted
Seeing that you have not solved your answer. I have created a new sheet in your spreadsheet showing you a possible answer.
Possible solution
Basically you can have a dynamically expandable sheet with the use of ARRAYFORMULA.
Which is kind of basically repeat this operation for the whole range. In this case you just would need to put one formula for each column:
=ARRAYFORMULA(IFERROR(VLOOKUP(A:A;'Customers static'!A2:D;2;FALSE)))
Look how instead of using a single value for VLOOKUP you are using the whole range and ARRAYFORMULA will handle that. Therefore you just need to write the formula at the top of each column, changing the index for every single column in the original data.
You can take a look in the Raserhin's help on the sheet you have provided.

Excel to remove duplicates (like a SELECT ID, max(Monday), max(Tuesday)

I've got a csv from a 3rd party that is imported into Excel that I cannot figure out how take the data that looks like this so that each row is collapsed down and the blanks are gone. In SQL I would just do a select on the fields I want and de-dupe those, then max on the others to get rid of the blanks. How would this be done in Excel?
Data:
Expected results:
Assumption:
1. you only need to do this once
2. Your source data starts at A1 (the headers)
3. The list of IDs are sorted and with fixed number of rows for each ID (6 rows in your example) .
Steps:
Create a new worksheet
Fill column B with the list of unique ID (in the same order as your data), start with B1
Fill column A with a serial number: 0,1,2,3,4.... up to the number of unique IDs, start with A1
Fill in column C the following formula
=TEXTJOIN("|",TRUE,OFFSET([src worksheet]!$B$2:$O$7,A1*4,0))
Then you should be able to use "TextToColumn" function to make the table you want.

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'));

How to leave a blank field in table in sqlplus?

In sql, if some fiels are to be left blank while inserting the values in the table, how shall we do it?
For eg. For name field, i want to insert 'First Name' & 'Last Name' but not 'Middle Name'.
But the field is already present by default in the table.
If I have understood you correctly, you simply need to execute an INSERT sentence, without using the columns (fields) you don't want to inform.
As an example, if you have three columns and don't want to inform column2 use
INSERT INTO table_name (column1,column3)
VALUES (value1,value3);
instead of
INSERT INTO table_name (column1,column2,column3)
VALUES (value1,value2,value3);
Hope it helps!

do some calculations in a table using dropdowncombo

I have a field in my database called 'Stock'. It displays how many items are there remaining for sale.Now I have a dropdowncombo with values like 1,2,3 etc... So now when I select an item in the grid and click the button SELL I would like the 'Stock' field of the item in question (in the grid) to decrease by the amount that was in the combo. So if the 'stock' was 100 and I sell 5 (dropdowncombo value) I would like the grid value to display now 95. I hope you know what I mean... I could do this with inserting a calculated field but I do not want to. Better an UPDATE ... Any ideas
something like UPDATE MyTable set STOCK = (Mytable.fieldbyname('stock').asInteger - dropdowncombo1.value)
dont have delphi here with me so unsure does this work on selected record in the grid...
abstable1.edit;
abstable.FieldByName('stock').value := abstable.FieldByName('stock').value - strtoint(cxcombobox1.text);
abstable1.Refresh;
This does the job ...

Resources