I want to know if it's possible to load an Excel Validation list directly from an external query. I'm expecting to do this in VBA somehow. I have the query which works fine and I can load the resultant list into a table in a worksheet via VBA without a problem, but I wanted to know if I can use this result set directly into a validation list without having to first load the query results into a workbook and then refer to this table as the source for the validation list.
I'm working with MySQL and Excel 2016 and the combination works well for everything so far, but I'm stuck on this. Any ideas please?
Yes, you can and it is easy if you use Excel tables.
You need to always save the records returned from your SQL query into an Excel table. You can create it each time or you can just create one, rename it and always keep it there in a visible or hidden worksheet. It depends on you.
Let's say that you have created an Excel Table that keeps the options for your drop down list and it is called Table1. The trick is when you are defining the validation in the cell (or cells), in the Source section you write this:
=INDIRECT("Table1")
Related
I'd like to automate a procedure some. Basically, what I do is import a few spreadsheets from Excel, delete the old spreadsheets that I previously imported, and then change a few queries to reflect the title of the new imports. And then I change the name of the queries to reflect that I've changed them.
I suppose I could make this a bit easier by keeping the imported documents the same name as the old ones, so I'm open to doing that, but that still leaves changing the queries. That's not too difficult, either. The name stays pretty much the same, except the reports I'm working with are dated. I wish I could just do a "find and replace" in the SQL editor, but I don't think there's anything like that.
I'm open to forms, macros, or visual basic. Just about anything.
I've just been doing everything manually.
Assuming I have correctly understood the setup, there are a few ways in which this could be automated, without the need to continually modify the SQL of the queries which operate on the imported spreadsheet.
Following the import, you could either execute an append query to transfer the data into a known pre-existing table (after deleting any existing data from the table), avoiding the need to modify any of your other queries. Alternatively, you could rename the name of the imported table.
The task is then reduced to identifying the name of the imported table, given that it will vary for each import.
If the name of the spreasheet follows logical rules (you mention that the sheets are dated), then perhaps you could calculate the anticipated name based on the date on which the import occurs.
Alternatively, you could store a list of the tables present in your database and then query this list for additions following the import to identify the name of the imported table.
I'm trying to TextJoin in Access, I was able to complete this in Excel for a entire row by using the below formula:
=TEXTJOIN("",TRUE,F2:F251)
How do I replicate this in Access?
MS Access uses a completely different paradigm to Excel. There is no way of doing this without handcrafting it in VBA code.
Loop through the recordset rows and concatenate the column values to a variable. You can't really rely on the column order being correct in a for/next loop so you might have to refer to the columns by name.
In Microsoft Access I need to display a table with the headers down the left side, instead of being across the top. So far I've found a lot of people asking this sort of thing, but no good solutions. I have found that Microsoft supplies a VBA function to do this:
Method 2 at http://support.microsoft.com/kb/202176
That function creates another table in the access database. I will modify that so that instead of creating a new table, it either prints the table to the form calling the function or returns a table, depending on what Access is able to do.
Can the Record Source property be set to a function? I haven't seen a way to do this so far. If that's not possible, in the Form_Load() event, what commands could I use to manually create a datasheet (providing the rows and columns in transformed order).
Thank you for your advice.
I have a general question about Microsoft access append queries.
Heres the background of what Im trying to do, We have a online database with contact information on people that I pull down monthly via a excel file. I import it in to a table and now I'm trying to append that into a table that contains not only the fields in the table but a few more with certification dates.
Now, my question is, how can I have the append query check that the record im bringing in is the same person as the one on the original, and have it overwrite without any changes. Is that just how a append query works or does it it require some coding to make it do that?
tl;dr? Append query, how do I make it not overwrite over the wrong records?
I've had no formal education and Its been hard to find data on the subject.
Append queries do not check for matches or duplicates. Append queries append new records, but do not append new data to existing records.
For what you have there I recommend using VBA. I think it would be simplest to use ADO to open a recordset based on the excel sheet, and then use DLookup or DCount to see if a matching record already exists before performing the insert or update statement.
I have two excel source 1st is giving me date value and 2nd is giving me price value from excel sheet.
Now i need to insert these two values into one table please tell me how can i do this?
I have used merge join but it is giving me error input must be sorted that i can't as it excel file.
Well personally, I would put each Excel file into it's own staging table. Then I would use a SQL query that joins the two tables as the source for my insert to the production tables.
After you get the input from each source, you have to sort it prior to merging it.
You can sort the input from an Excel source, from any source, because the sort is performed with the data on memory. Its an element in the Toolbar.
Check this:
http://msdn.microsoft.com/en-us/library/ms137653.aspx
I'm pretty sure you can define a sort on an excel