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.
Related
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")
Trying to convert this MS Excel formula
=IF((D2+C3)>0,0,(D2+C3))
How would I convert it into MS Access or VBA?
This is the dataset table in Excel that we are importing into Access
Try something like this:
=IIF(([Rollover]+[Bucket])>0,0,([Rollover]+[Bucket]))
Although, your Excel formula references D2 and C3, in different rows. That's going to be a bit tricky in Access if that's what you really need to do. It is possible to do, if that's what you really want, but you may need to add a ROW Number field (or an autonumber ID field) in order to do that.
Blair
Editted: (since I just read the "see more comments")
The quick and dirty way to do this is to add the RowNumber field, the make a query from the dataset with a calculated field output NextRowNumber: [RowNumber]+1. Link the query and the dataset together with RowNumber and NextRowNumber. Use the [Rollover] field from the query ([Query]![Rollover] and the [Bucket] field from the dataset ([dataset]![Bucket]) in the equation above.
There is likely a more elegant way to do this in VBA, but the linked query / dataset should work.
Blair
Is there a way to write data to an excel spreadsheet after skipping x number of rows...excel is my destination and a sql query would be my source?
My scenario is one where i have a lot of header rows that i need to skip before data insertion. I would like to do this in an SSIS package. I am using SQL 2008 and Excel 2010.
Thanks
if you right click on the excel connection manager at the bottom of the page than click options , there is a setting called FirstRowHasColumnName set it to FALSE .let me know if it helps , didn't really understand if you just want to skip the first row that is the name of the columns from SQL query or more , there are other ways
Easiest way would be to modify your SQL query to exclude the header rows. If you can't do that then you need some logic to determine if the row is a header row (like checking if a certain field is a number):
If you can do that then you can do this:
read all columns in as text
Put in a derived column where you generate a new column IsHeader using your logic
Use Conditional Output to filter out the rows where your IsHeader is true
Use Data Conversion or Derived column to convert the columns to correct datatype
Output to Excel as usual
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'm in the process of converting a MS Access 2000 database to MySQL, while still using Access for the front end.
I've come across a problem where some forms get the data from fields in MS Access tables. IE, the "Control Source" value is set to a specific field, and when the form is run, its creates the required number of Textboxes to match the number of entries in the table and populates them with the data from the tables.
Now I'd like to be able to set the Control Source of the Textbox to call a VBA function, which get's the data from MySQL, and populates the textbox with the entries in MySQL table. I'm not sure how this is achieved, or if its even possible.
So could I just create a VBA function and set it in the Control Source property for the Textbox, or do I need a more complicated solution ?
You do not need any code for the text boxes to display. Simply use a linked table to MySql, and the form should function as before. There is little if any reason I can think of here to dump the use of bound forms and bound controls.