SELECT f.card_serial_num, count(1) AS CardRxCnt
FROM [Excel 8.0;HDR=Yes;Database=C:\Users\Mike\Desktop\er.xls].[er$] AS f
WHERE f.location_name not like 'PREPACK'
and f.card_type not in ('PRN','sequential')
and (f.card_due_date = #9/15/2014# or f.card_due_date = #10/1/2014#)
GROUP BY f.card_serial_num
HAVING CardRxCnt >2
I have a problem with HAVING CardRxCnt >2. If I take out, I get my query returned.
But if I have it in, it somehow prompts for an input and so when I just put 1 it
returns nothing. Actually without CardRxCnt, sometimes the query prompts
for an input at which I enter 1 and the query executes. Yet other times it would just go through. So my question is two part:
what could be causing this random behavior of "asking"? I know to prompt for a user input, I have to surround a value with []. Could it be the Excel part?
CardRxCnt (in SELECT and HAVING): I don't see what's wrong with it but when I add this, query does not work.
Please help. And I can't do VBA/macro here so if you're gonna say why don't you query with VBA it's not a solution for me.
Related
New Member Here - Happy to Be With You!
I'm Hoping you can help me with what seems to me to be a syntax issue. I have a report with multiple subreports, all of which are based upon queries. The queries have criteria to prompt the user to [Enter SampleID]. When I run the report, it works correctly but is cumbersome because I am prompted for each criteria individually so I wanted to create a form with a button and an input field for the user to enter a SampleID. Then the code would pull that SampleID and use it to "answer" the criteria prompts. Clearly, what I have done so far is incorrect as I receive a run time error 13 type mismatch...I tried to find guidance as to how to proper syntax for strings, but those edits don't seem to work :(
Here's the start of the current code for your review and insights - it continues on but the syntax is the same throughout. Note that SampleID is a short text string.
DoCmd.OpenReport "DEV_GenRpt_Comp_Info", , , "Samples.SampleID=" & Me.SampleID And "ReportDemos_TestOrderAndSampleReportInfo.Samples.SampleID=" & Me.SampleID And "200_8_Query.SampleID=" & Me.SampleID And "300_Query.SampleID=" & Me.SampleID
Most appreciated!
First of all I would like to tell you that I have just basics with VBA or Visual Basic. So probably there will be better solution in VBA, but I was unable to find a way. That's why that my attempt is so crude. Also my english can be somewhat broken sometimes. I'm sorry for that.
Below you can find screenshots from my excel sheet. You can notice functions are in czech language. You can find translation below.
Screenshot with actual results:
Screenshot with actual functions:
Translated functions:
AA =COUNTIFS(A:A;X2;D:D;D129)
AB =IF(AA129=1;CELL("address";INDEX(D:D;MATCH(D129;D:D;0)));"NULL")
AC =IF(AA129=1;REPLACE(AB129;2;1;"M");"NULL")
AD =IF(AA129=1;CONCATENATE("=IF(";"""";M129;"""";"=";AC129;";1;0)");"NULL")
AF =ISNUMBER(AE129)
AG =IF(AF129=TRUE;CONCATENATE(AE129);0)
Description:
Every day someone downloads .csv files from JIRA and uploads it to excel. That csv contains test cases. Column X has the date when this csv was uploaded, Column D has the ID of the test case. Column M has the date of the last change on that test case.
Functions description:
AA: It searches if there is the same test case in previous day. If yes, then result is 1. If no, Result is 0.
AB: Locates the exact cell location of the same test case from previous day.
AC: Serves for translation from ID column (D) to last change column (M).
AD: Composes translated information from AC, so it will create a function, which I would like to use further. That function will compare last change date with the test case from previous day and current day. Result should be 1 or 0 depending on if there was any change.
AF: Checks if AE is number (AE should be the column where I would like to run
that function from AD).
AG: If AF is true, then it copies value from AE. Else it's 0
Problem is:
I can't find a way to trick excel to take the text from AD and use it as function in another cell. Tried to program it in VBA, but failed.
What I need:
Translate result from AD from text to function and then run it in AE.
If there is a more efficient way to program this, I am open to suggestions. But I would like to have an answer for my question as well. I want to know if it's possible because I will make more complicated cases later while I learn to work with VBA.
Thanks for the response.
I would just like to say that I'm very new to VBA and more complicated formulas so all the help will be appreciated! Thank you!
To clarify a bit more with the title. I currently have a Macro that is reading a formula to give me information from another worksheet. I'll give an example of the formula that is working:
=IF(A2 = ""No Specific Program"", A2,IF(F2 = """",""No PIN"",IFERROR(VLOOKUP(CONCATENATE(A2,F2),....!$C:$I,4,FALSE),""NO DATA"")))
This is the original formula that I'm using to get the information, column A is my Parts owned by Program, And my column B is the actual Program. So when I run the Macro it does give me most of the information, but when it runs into "No Specific Program" even when there is something for Column B showing what program the part is in, it will give me No specific Program.
Also for reference the F2 it is Concatenating is a PIN number which will help determine who owns the part.
I've been stumped on this trying to get the code to work and I've tried place THEN and ELSE within the statement and it just gives a FALSE statement
EDIT:
The Code above works, it's when I use this version of the Code:
=IF(A2 = ""No Specific Program"",THEN,IF(F2 = """",""No PIN"",IFERROR(VLOOKUP(CONCATENATE(A2,F2),'.....'!$C:$I,4,FALSE),""NO DATA"",Else,IF(A2 = ""No Specific Program"",THEN,IF(F2 = """",""No PIN"",IFERROR(VLOOKUP(CONCATENATE(A2,F2),'.....'!$C:$I,4,FALSE),""NO DATA"")))))
I get the False or errors when I try different variations. Here is an example of the columns. Column A is where I have the original formula reading from, but then it says No Specific Program, while Column B shows the Program. So I'm trying to get the formula to read that as well as column A to capture all the information I need :
Columns Example
EDIT:
It starts breaking after the ELSE statement.
Edit:
=IF(A2 = ""No Specific Program"",
IF(F2 = """",""No PIN"",IFERROR(VLOOKUP(CONCATENATE(B2,F2),'\NW\Data\TechIntegration\Sustaining
Team\Data
Mining\DataMining[GAD_PIN_TABLE.xlsx]Sheet1'!$C:$I,5,FALSE),
""NO GAD
DATA"",
IF(F2 = """",""No
PIN"",IFERROR(VLOOKUP(CONCATENATE(A2,F2),'\NW\Data\TechIntegration\Sustaining
Team\Data
Mining\DataMining[GAD_PIN_TABLE.xlsx]Sheet1'!$C:$I,5,FALSE),""NO GAD
DATA"")))))
Just trying to make it easier to see the formula.
I'd split this down to make it simpler to follow, use a holding cell then refer to that in your top formula (The one you know works already)
Stick this in another column, say Z for example, then everywhere you refer to A2 in your working formula, change it to Z2
=IF(A2=""No Specific Program"",IF(B2=""No Specific Program"",""No Specific Program"",B2),A2)
This will only give you "No specific program" if both a2 and b2 contain "No specific program" which I think is what you're after. In your second example in the columns example link, it will return NG
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...
I have stored proc Im pulling in to excel but to get it to Run I have to enter my text exec roc 'Name' I need it to be able to have someone else thats running it be able to enter a name as they refresh the data. I dont know VBA at all and am looking for help.
I don't completely understand your question but if my assumption is correct... you want to have a cell where someone can enter some sort of name, where you can then use their input to do some other operations.
To start, you would want to grab a string variable (by grab I mean create)
Example:
Dim strName As String
Then you would want to be able to read a specific cell.... In the next example the cell will be A2
Example:
strName = Range("Sheet1!A2").Value
If you named the first sheet something different use that name. If the user inputs a name into that cell you can then use it later to do calculations or anything you want.
If you are not using VBA code then what are you using?
If using MS Query, try changing the SQL text to
{CALL roc(?)}
and IIRC this should prompt the user to enter text for the parameter value.