I have a problem with a SQL Statement in VBA Excel. I can’t use ORDER BY together with GROUP BY and I don’t understand why. If I delete ORDER BY I don’t get errors. Can anyone help me figure out where am I wrong? Thanks a lot to everyone!! Here is my code: Answer missing space ? try with
Tag: vba
syntax error (missing operator) in query expression – VBA and Access
I build a query with this syntax: I did a test query in MariaDB, and it worked. Now, i am use this query in Access with VBA MSExcel, where it has the same structure and relationship between tables, but return error. message error vba: Syntax error (missing operator) in expression ‘t.id_empresa = e.id_empresa LEFT JOIN responsavel AS r ON t.id_respons’
Select Top X records starting at record Y
I am using MS Access VBA to make a few queries. I have a list of about 4000 items and I need query 1 to be the top 739 items and query 2 to be the top 428 items starting at record 740 and I need query …
insert Into and Union of Tables
I’m using MS-Access. I have a table A looks like : I need to insert into a table B that looks like: Can I do it with an SQL instruction? Answer If the id field in table B is an Autonumber and ordering of the values is important, then you can use keep in mind that the value field name
Excel SQL VBA: adding more than one cmd parameter
I am writing SQL-query, and I get error with string value: I tried to add more than one cmd parameter to solve this problem: But I also get an error. How do I set more than one cmd parameter and use it in my query? Table I am working with: here. Answer The parameter to CreateParameter are The Direction –
Sql string with OLEDB gives error 1004 in VBA
I would like to import a text file into excel filtering just what I want through a VBA macro. When I use LIKE operator in the sql string I get the error 1004. I have tried both * and % as wildcard and ALike instead of Like but there is no difference. test_7.txt and the macro is: Answer SQL statements
SQL select single row number x only
For processing SQL data in VBA I want to use a loop (For…Next) that reads line by line from a SQL database. As records were deleted the ID column has gaps. The table looks for example like this: Having four lines I would like to run of course a “For each” would do good, too. Answer If you want 4
Adding parameter to SQL query
I want to get some data from Excel table using SQL-query inside macros. My code is: If I try using sql = “SELECT * FROM [Page 1$] WHERE Job = 2”, I have no errors. How could I paste Value2 and Value1 values inside my SQL-query? Answer Try like this
Reading Excel file with SQL returns null due to empty column
I am attempting to read in an Excel File from a third party but it falls over and returns null due to empty column. The file has 50 columns, a blank column and a further 48 columns. I only want the first 50 columns. If I delete or populate the empty column in Excel it works but I need to
VBA error while querying a Tab limited Text file with headers – “no value given for one or more required parameters”
My Text file is Tab delimited and does have the header Field “Datum”. I intend to read the data between two given timestamps (along rows) into an Excel File and figured using the ADO and SQL approach would be the best way to go about it, since this would avoid use of arrays and looping. My Text file looks like: