Undefined function 'Concat' in expression. for Bartender SQL Statement - sql

I'm currently setting up a label on Bartender. Currently I'm on Database setup screen and already have connected an excel sheet to it.
Inside an excel sheet, I have a column that is prefixed with a barcode number starting digits are '5011'. Inside an excel sheet I can select few records and drag down to generate more barcodes. e.g. if you have numbers going down a cell 1,2,3... and you select all three and drag down you have numbers following up with4,5,6,7,8 etc... same principle with my barcodes.
But.. the '5011' needs to start with a '0', so it becomes '05011'. If I format my barcodes with an '0' and drag down, cells do not update to what they should to. e.g. 01,02,03.. will continue like this: 03,03,03,03,03 repetitively.. even when refreshing the workbook with F9
I need an SQL query that just simply adds an extra '0' at the start for the barcode column and shows all results within the sheet.
I have managed to use this query to run on excel sheet:
`SELECT * FROM [Sheet1$];
just not sure how to add that extra 0 for column named Outer Barcodes
and have tried this:
UPDATE `Sheet1$` SET `Outer Barcode` = Concat('0',`Outer Barcode`)
but an error message comes up with:
Undefined function 'Concat' in expression.

The concat() operator in MS Access is &:
UPDATE [Sheet1$]
SET [Outer Barcode] = '0' & [Outer Barcode];

Related

I would like to match the data of two columns in two different excel workbook

I have two excel WORKBOOK (WB)
In excel WB 1, I have column for student IDs and Advisor name.
In excel WB 2, I have IDs to be matched to WB 1 IDs if the Advisor name is "John" to show "TRUE' in a column in WB2.
Can you pls tell me what are the formulas to try AND EXPLAIN THE COMPONENTS OF THE FORMULA?
aTTACHED IS THE SCREENSHOT OF DATA.
pLEASE NOTE ITS IN DIFFERENT EXCEL WORKBOOKS NOT SHEETS.
Taking your provided formula I will run you through the minor change that will make this work:
=IF(ISNUMBER(MATCH(C7:C17&"John",'[wORKBOOK1 NAME]SHEET1'!$A$2:$A$13&'[wORKBOOK1 NAME]SHEET1'!$B$2:$B$13,0)),"True","False")
This of course is assuming that the Forenames are in $B$2:$B$13...
What this is doing is simply forming a string value of the ID with the Forname stuck onto the back of it. MATCH will reference an array of values that it creates from the criteria within itself - the ID with the Forename.
The match formula will work in the same way, returning an integer representing the index location within the array when the match is found.
I will point out that the formula does not accept an array for the first argument, so currently only the first cell is being searched... You will want to update the formula and perhaps have this as a column checking each individual ID:
=IF(ISNUMBER(MATCH(C7&"John",'[wORKBOOK1 NAME]SHEET1'!$A$2:$A$13&'[wORKBOOK1 NAME]SHEET1'!$B$2:$B$13,0)),"True","False")
If you wanted this as just one formula it gets a bit more complicated as you must form an array using an if statement and Evaluate against that array:
=IF(ISNUMBER(MATCH(1,IF(C7:C17&"John"='[wORKBOOK1 NAME]SHEET1'!$A$2:$A$13&'[wORKBOOK1 NAME]SHEET1'!$B$2:$B$13,1,0),0)),"True","False")
This must be entered as an array formula (While still in the formula bar hit Ctrl + Shift + Enter)
The if statement will check for the match and build a new binary array (1 for a match and 0 for no match), the MATCH formula then is simply checking if a match is found in that new array by searching for 1.

SQL query to link data in 2 Excel sheets

I want to link 2 excel tables on different excel sheets. I do this for years without problems. Both excel sheets contain a table with the same reference number so i can link them and job done.
The Excel sheet i got this time from the vendor has little different reference numbers. They all have a character in front of the reference numbers.
Sheet 1: Reference number: 12455630098
Sheet 2: Reference number: F12455630098
The problem here is that the data is a little different now, so the link can't be made with the code i used previously.
SELECT `tab1$`.Référencenumber, `tab1$`.Price, `tab2$`.PARTNO
FROM C:\xxxxxxxxx.file.xlsx
WHERE `tab1$`.Référencenumber = `tab2$`.PARTNO
I tried to experiment with the wildcard character to get the job done, but without succes.
This is my SQL code so far.
SELECT `tab1$`.Référencenumber, `tab1$`.Price, `tab2$`.PARTNO
FROM C:\xxxxxxxxx.file.xlsx
WHERE `tab1$`.Référencenumber LIKE '%' + `tab2$`.PARTNO
Whats wrong here?
Why not
SELECT `tab1$`.Référencenumber, `tab1$`.Price, `tab2$`.PARTNO
FROM C:\xxxxxxxxx.file.xlsx
WHERE `tab1$`.Référencenumber = substring(`tab2$`.PARTNO,2,11)
The easiest way is to run a replace command.
Press CTRL+H and when the replace dialog opens search for letter F and replace it with nothing.
Ok, in your previous question you did not made that specific, didn't use SQL in MS producst for a long time, but if I'm right than you there isn't substring function in MS office, instead you have LEFT RIGHT and MID so you should try something like:
SELECT `tab1$`.Référencenumber, `tab1$`.Price, `tab2$`.PARTNO
FROM C:\xxxxxxxxx.file.xlsx
WHERE `tab1$`.Référencenumber = MID(`tab2$`.PARTNO,2,LEN(`tab2$`.PARTNO)-1)
Not 100% sure about the keywords...

MS Access: Trim a leading character upon input into form field

I'm building an access database, and on my main form, I have a field called "PartNumber." I want to scan data (a part number) into this field using a USB scanner and barcode. However, the barcodes include a leading "P" that isn't actually in the part number, and only serves to identify what kind of object that number is assigned to. I would like to automatically remove that P when I initially scan the data, so that the database stores and displays the correct part number.
I thought about using a query with an expression involving mid() and len(), then setting the control of the form field to that field in the query. However, that won't let me change or input data in the form's table, so it's useless for any records not already in the table.
Any ideas are greatly appreciated. Thanks!
I would do this with VBA, in the AfterUpdate event of the textbox.
Private Sub PartNumber_AfterUpdate()
If Left(Me!PartNumber, 1) = "P" Then
' Remove the first character
Me!PartNumber = Mid(Me!PartNumber, 2)
End If
End Sub
Depending on how the barcode API VBA runs: update tables via SQL or updates current form record in VBA; updates in bulk or updates one at a time. Either way at end of bar code reading when updating field, simply use Replace() in VBA or SQL:
SQL:
UPDATE tablename SET fieldname = Replace(fieldname, 'P', '')
VBA:
Me.fieldname = Replace(Me.fieldname, 'P', '')

VBA script in excel to find and highlight text

I am looking for a VBA script that will help me find certain keywords in a cell and if found highlight the entire row. Below are my requirements:
I have a database of words eg hell, get out, shut up, don't you dare etc. I need a macro to search the data in column "E" of excel and in case any of the cell in column "E" contains any word listed in the database (irrespective of the case of the word upper or lower)the entire row is highlighted. The word can be in the beginning, middle or end of the cell and the macro should be able to find that word and highlight the column.
Seeking help from all VBA masters for this.
You can do this with conditional formatting, instead of VBA.
Conditional formatting works by applying a 'second formula' to a given cell. If the 'second formula' results in TRUE, then special formatting conditions can be applied.
EXAMPLE CONDITIONAL FORMATTING
For example, if you have a single column of Data, A:A, and you want to check if that column has the exact string "hello world", you could add a conditional format [Home ribbon, Styles section, Conditional Formatting] that turns a cell yellow with this formula:
=$A1="hello world"
This will only result in TRUE if the cell in column A at that row equals exactly "hello world" [note that Column A has an absolute-reference $, and row 1 does not, so row 1 is relative to the position of the cell in the condiitonal format rule].
To check to see if any row in column A includes hellow world, we need to add a SEARCH function, which checks to see if a small search string is inside of a larger string:
=SEARCH("hello world",$A1)>0
Because SEARCH by default returns the first character in a larger string that matches the search term (and if it finds nothing, it returns #N/A), we check to see if our search for "hello world" in column A returns a number.
SEARCHING MULTIPLE COLUMNS
Now, to see if ANY column, say from A-D, includes "hello world", we concatenate each value of each column so that it gives us a single string, which we can search through for "hello world", like so:
=SEARCH("hello world",$A1&$B1&$C1&$D1)>0
This will first create a single string, equal to A1 & B1 & C1 & D1 all in a row. Then it will search that newly created string to see if "hello world" is inside it, and return a number value if it is.
ARRAY FORMULA BASICS
Finally, we need to do the tricky part - searching for multiple terms instead of just "hello world". This is called an Array Formula. An array formula works by performing a single operation on multiple cells, and then returning multiple results in an Array. In an Excel sheet, an array formula must be confirmed with CTRL + SHIFT + ENTER (instead of just ENTER), but in conditional formatting, you actually don't need to do anything special - it will recognize an array formula without a special command.
As an example of conditional formatting, see this example, which checks whether any value from A1:A5 = 10, and if it does, it gives us the value in B1:B5:
=IF(A1:A5=10,B1:B5,"")
Remember in Excel on a worksheet, this would be confirmed by pressing CTRL + SHIFT + ENTER. If you do test this, it will give you the following result, assuming A2 = 10 and A5 = 10:
={"";B2;"";"";B5}
This result would actually be hidden, because Excel can't "collapse" an array function on its own. So assume column B had values, and we actually want to sum them together. We would then wrap the Array formula in a SUM function:
=SUM(IF(A1:A5=10,B1:B5,""))
As you can see if you test this, we have actually created our own SUMIF function, using Array formulas instead of the built-in SUMIF.
SEARCHING FOR MULTIPLE TERMS WITH ARRAY FORMULAS
So now we apply these principles to the conditional formatting, to create an array formula which will check our concatenated 'NEW STRING' for any number of provided terms, as follow [Assumes the search terms are typed into cells E1:E10]:
=SUM(SEARCH($E$1:$E$10,$A1&$B1&$C1&$D1)>0)
This formula can be placed as a conditional formatting rule which reaches all of A:D. Set the rule to highlight / change format in whatever way you like.

Column references in formulas

I am a little stuck at the moment. I am working on an array of data and need to find a way to input column numbers into formulas.
-I have used the match function to find the corresponding column number for a value.
ex. "XYZ" matched with Column 3, which is equivalent to C1:Cxxxxxx
-now for inputing the C1:Cxxxxxx into a formula to get data for that particular column, I would like to be able to directly reference the Column 3 part, because I plan on using this workbook in the future and the column needed to run the calculation may or may not be column 3 the next time I use it.
- is there any way to tell excel to use a formula to tell excel which column to use for an equation?
so a little more detail, I have the equation
=AND(Sheet3!$C$1:$C$250000=$A$4,Sheet3!$B$1:$B$250000=$B$4)
instead of specifying to use column C, is there a way to use a formula to tell it to use C?
EDIT: more additional info;
"i am basically running the equivalent of a SQL where statement where foo and bar are true, I want excel to spit out a concatenated list of all baz values where foo and bar are true. ideally i would like it to ONLY return baz values that are true, then I will concat them together separately. the way I got it now, the expression will test every row separately to see if true; if there is 18K rows, there will be 18K separate tests.. it works, but it's not too clean. the goal is to have as much automated as possible. *i do not want to have to go in and change the column references every time I add a new data arra*y"
Thanks
You can use INDEX, e.g. if you have 26 possible columns from A to Z then this formula will give you your column C range (which you can use in another formula)
=INDEX(Sheet3!$A$1:$Z$250000,0,3)
The 0 indicates that you want the whole column, the 3 indicates which column. If you want the 3 can be generated by another formula like a MATCH function
Note: be careful with AND in
=AND(Sheet3!$C$1:$C$250000=$A$4,Sheet3!$B$1:$B$250000=$B$4)
AND only returns a single result not an array, if you want an array you might need to use * like this
=(Sheet3!$C$1:$C$250000=$A$4)*(Sheet3!$B$1:$B$250000=$B$4)
You could use ADDRESS to generate the text, you then need to use INDIRECT as you are passing a string rather than a range to the fomula
=AND(INDIRECT(ADDRESS(1,3,,,"Sheet3") & ":" & ADDRESS(250000,3))=$A$4
,INDIRECT(ADDRESS(1,2,,,"Sheet3") & ":" & ADDRESS(250000,2))=$B$4)
Obviously replace the 3s and 2s in the ADDRESS formulae with your MATCH function you used to get the column number. The above assumes the column for $B$1:$B$25000 is also found using `MATCH', otherwise it is just:
=AND(INDIRECT(ADDRESS(1,3,,,"Sheet3") & ":" & ADDRESS(250000,3))=$A$4
,Sheet3!$B$1:$B$25000=$B$4)
Note a couple of things:
You only need to use "Sheet3" on the first part of the INDRECT
Conditions 3 and 4 in the ADDRESS formula are left as default, this
means they return absolute ($C$1) reference and are A1 style as
opposed to R1C1
EDIT
Given the additional info maybe using an advanced filter would get you near to what you want. Good tutorial here. Set it up according to the tutorial to familiarise yourself with it and then you can use some basic code to set it up automatically when you drop in a new dataset:
Paste in the dataset and then use VBA to get the range the dataset uses then apply the filter with something like:
Range("A6:F480").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Sheets("Sheet1").Range("A1:B3"), Unique:=False
You can also copy the results into a new table, though this has to be in the same sheet as the original data. My suggestion would be paste you data into hidden columns to the left and put space for your criteria in rows 1:5 of the visible columns and then have a button that gets the used range for your data, applies the filter and copies the data below the criteria:
Range("A6:F480").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Sheets _
Range("H1:M3"), CopyToRange:=Range("H6"), Unique:=False
Button would need to clear the destination cells first etc, make sure you have enough hidden columns etc but it's all possible. Hope this helps.