I want a combo box that can do a query search from multiple fields and return the product ID. The function of this combo box is that there are three fields product ID, Name and bar code. Now the user searches from any one of those fields and the option should come from those three fields, after the user selects an option it should store it as the product Id. I tried working on this problem but the only far I could go was that i could only search from one field for example by only its name. So is this function possible to code and if it is then how to code it?
If you want user to enter ProductID, Name, or bar code into same combobox and return the ProductID, then make the combobox RowSource a UNION query of the three fields:
SELECT ProductID, ProductID AS Data FROM tablename
UNION SELECT ProductID, ProductName FROM tablename
UNION SELECT ProductID, BarCode FROM tablename;
Set other combobox properties:
ControlSource: field to save ProductID into
BoundColumn:1
ColumnCount: 2
ColumnWidths: 0";2"
Strongly advise not to use spaces nor punctuation/special characters in naming convention. Also, Name is a reserved word and should not use reserved words as names for anything.
I'm using Microsoft Query to pull data from MS SQL Server to Excel. Many of my tables have the same column names, for example:
[task].[active]
[user].[active]
[task].[name]
[user].[name]
When I pivot in Excel, only the column names are shown. A pivot filter might have multiple fields called "active" which is very confusing.
I'd like to alias every column with the table name it's from, so that in the filter it would say "task_active" and "user_active". My Excel SELECT statement would be:
SELECT active AS task_active, name AS task_name FROM task...
Is there a quick way to prepend the table name to an alias using a formatting tool? I have Apex SQL Refactor, and Notepad++ but I haven't found a way to do this without having to manually type all of the column names again.
If you populate resultset to datatable then datatable to excel then it will automatically change duplicate column name to col1,col2 etc.
This is not your requirement.you want it to be specific.
Method 1 . Create temp table with desire column name
Insert the result in #temp table
Return #temp table result set
Method 2 : Use dynamic query.
Wht your real query look like ?
My Query is like below for Table...,
Create Table t_raw
(
Month nvarchar(255),
Name nvarchar(255),
Clear nvarchar(255),
Contact nvarchar(255),
Viewed nvarchar(255),
Clicks float
)
Insert Into t_raw values('Jan-18','ABC','DTC','dtc#mz.com','GM','2'),
('Feb-18','QSC','FMM','fmm#mp.com','AM','6'),
('Mar-18','ABC','DTC','lta#mz.com','OPS','9'),
('Jan-18','MHY','GNMA','gnma#sr.com','REP','3'),
('Feb-18','VRL','XLR','xlr#vn.com','TUC','5'),
('Mar-18','MHY','GNMA','gnma#sr.com','XEM','7'),
('Jan-18','ABC','DTC','mat#sd.com','SUD','2'),
('Feb-18','MHY','GNMA','mio#fr.com','AFT','4'),
('Mar-18','TOC','ADF','fin#yu.com','BPL','2')
Below is the table:
I am expecting the below output like below.
Can anybody help me achieve this desired output?
Create a blank report and create a Data Source and a Dataset to connect to the data. Add a Matrix to the report. Drag the Name fiield from the Dataset in the "Report Data" window to the first "Rows" field of the matrix and select the Month field using the field selector in the Columns header field. Select the Clicks field in the data cell under the Month header, this should automatically result in a Sum. In the properties window of the Month Column Group change the sort order to an expression like
=CDate(Fields!Month.Value)
Change the width of the Name field to be wide enough to contain the four columns Name, Clear, Contact and Viewed (I chose 12 cm).
Now, right-click the Name header cell and insert a table via context menu. Don't worry about the hights and add an additional column in that table.
Do the same in the Name data cell
The design should now look like this:
In the table next to the Month field (I'll refer to that as "header table"), remove the Data row (and associated groups, when asked):
Then in the table next to the Sum(Clicks) field (I'll refer to that as "data table"), remove in turn the header row:
These steps resolve the problem with the hights.
In the "header table", enter the column names and format them as desired. In the "data table", select the corresponding fields to display. In the properties of the Row Group "Details1" of the "data table". add all 4 fields in the correct order for grouping and sorting.
For the fist 3 fields in the "data table", use the Properties sheet to set the HideDuplicates property to the name of your Dataset.
For the Sum(Clicks) TextBox, set TextAlign to "Center" and VerticalAlign to "Middle".
Oh, and add a total for the Name group of the outer matrix, align everything as desired.
VoilĂ :
Added:
To merge the cells for Name, Clear and Contact do the following:
In the properties of row group "Details1" of the "data table", remove Name, Clear and Contact under Grouping and under Sorting properties, so only Viewed is left. Rename the group to Viewed.
Remove the first three columns of the "data table" (Name, Clear and Contact).
Right-clicking always the topmost row group of the "data table", successivly add parent groups for Contact, Clear and Name.
I am taking user input from a series of combo boxes in a MS Access form, which might not all be chosen, so some will be "". But for the responses that are not "", I want to query those columns for the table the user has selected.
For example, this is my utopian solution which I'm I have no idea how to accomplish other than building a query for every possible combination and calling a procedure for that query:
SELECT **NON "" COMBOBOX CHOICES**
FROM T1
You can talk about the combobox field in the following syntax:
Forms![myForm]![myComboBox1Name]
The above returns the text from that box, either "" or a string they chose from the options. So in short, I was wondering if I inserted the valid non "" strings from those combo boxes into a table, then somehow used a SELECT statement on the table we could use the rows returned as the fields I want to query, example:
SELECT (SELECT * FROM ValidTable)
FROM T1
If the resource from the following link were successful, https://www.google.com/amp/s/blog.sqlauthority.com/2012/10/27/sql-server-storing-variable-values-in-temporary-array-or-temporary-list/amp/
I have a datagrid, which contains two columns.. second column will contain a dropdown .. The dropdown contains all the DB column names and when i select any DB column field from the dropdown then the field will be mapped to first column and the selected field from the dropdown will no longer exists in the dropdown.
when i clear the field from the first column, then the field will again bind to the dropdown, but the field is displaying at the last in the dropdown, so the field should not be displayed at last, it should display in it's previous place(i.e from the place where the field mapped from dropdown).
So can any one please let me know how to handle this is xaml.cs file.. That will be more helpfull for me...Thanks !!!
Initially i have declared an ObservableCollection OcCols = null;
//Used TableColumnsQuery in swith case case and adding all the column names from the table and then added the columns to OcCols.
TableColumnsQuery is declared as "SELECT COLUMN_NAME FROM information_schema.columns WHERE COLUMNPROPERTY(object_id(TABLE_NAME), COLUMN_NAME, 'IsIdentity')!= 1 and table_name ="
case "TableColumnsQuery", in the case adding all the columns from the table to OcCols and then adding the OcCols to the grid.
((GridViewComboBoxColumn)this.gridMappings.Columns[2]).ItemsSource = OcCols
Gridmappings is the grid name and second column has the combo box\dropdown which i have xplained earlier.
so now how to sort the columnfileds in the combobox/dropdown.
Thanks!!!