Modules & VBA :: Concatenate Data From Multiple Rows Into Single Row / Field
Nov 4, 2013
I use following function to concatenate data from multiple rows into a single row/field. It puts a comma ',' after each concatenate. What I would like it to do more is to put 'and' instead of comma between the last two concatenated words. For example: Now it gives me Value 1 but I want to get Value 2.
Value 1:
FormRegNo CombinedParticipants
DC-190 Political parties, CSOs, community residents
Value 2:
FormRegNo CombinedParticipants
DC-190 Political parties, CSOs and community residents
Function:
Option Compare Database
Option Explicit
Public Function ConcatField(strSQL As String) As String
Dim dbs As Database
Dim rst As DAO.Recordset
Dim strConcat As String
A third-party application I use exports data with 3 header rows. I usually have to go into Excel and concatenate the rows into a single header row, then export the file to Access to apply queries. I want to minimize the steps in this process, so I'm wondering if it's possible to do this concatenation in Access (with or without VBA).
I am trying to concatenate multiple rows into one record. I googled it and found many functions in VBA that do the job. However my problem is that my query will be linked directly to Excel file and then I get an error message saying that Excel could not recognise this function. I could potentially insert data into new table and link that table to Excel but I need to avoid end-user exposure to Access as much as possible.
So I am desperately trying to find a way of doing this without VBA code.
Example of data:
Customer Name |Order Number Smith |O101 Brown |O102 Smith |O103 Green |O104 Brown |O105
I am trying to achieve below:
Customer Name |Order Number Smith |O101, O103 Brown |O102, O105 Green |O104
To anyone who can help, I have created a function that loops through an amount of records and concatenates them into a single comma-separated string. What I would like to do is concatente the values into a list. Instead of:
value1, value2, value3
I would like to see
value1 value2 value3
This needs to be in a single record only. The code I am using is: ---------------------------- while not rec.eof string = string & ", " rec.movenext wend string=left(string,len(string)-2) --------------------------------
Thanks for all your help. I have tried to insert char(20), but this only seems to work in Excel. Access gives me invalid char symbol.
I have about 36 names and each of those names appears anywhere from 2 7 times each. Each name entry has a comment1 and a comment2.What I would like to do is create a form that allows me to choosea name and the display the comments 1 and comments 2 in text boxes.
I have made the form to allow me to choose a name and it shows one of the comment1 and one of teh comment2 in the adjacent text boxes as planned but, I want all the comment1s for Bob to show in the text box for comment1 and all of the comment2s for Bob to show in the Comment2 text box.I believe I need to concatenate the results in the comment1 and comment2 boxes, but I do not know where or how I would do that.
I'm trying to create a report that's based on a query, and the query has three fields: [PersonName], [PersonDate], [PersonShift]. This table holds records for people that worked on certain days and certain shifts. What I want to do is create a report that gives a graphical calendar display of each day in a month, and on any day that the person has a record (and sometimes there are more than one), I'd like to see just the PersonShift records showing in that day's box.
tblPersons PersonName PersonDate PersonShift Jason 4/10/14 FIRST Jason 4/13/14 FIRST Jason 4/13/14 SECOND
So if I were to print this report for Jason, I'd get all the days in April laid out like a calendar, and on 4/10/14 you'd see "FIRST" in the box, and on 4/13/14. you'd see FIRST and SECOND in the box. All the other boxes would be blank.how to display the calendar, how to display the dates. I'm able to return records to those boxes by creating 31 separate queries, one for each day of the month, and each query returns records for that day. The queries are added to the report as subreports. It all works beautifully.
The thing is, I'm running 31 queries every time I pull the report. Is there a way to code a single field on a report that will run a SELECT statement on the table using variables that are located in fields elsewhere in the record?
If I have a PersonName field on the header of the report, and I have a PersonDate field in the detail of the report's record, can I create a new field in the detail of that record that runs a SELECT statement on qryPersons, and filters the tblPersons by the PersonName on the header of the report and on PersonDate in the record?
I want a field on a report that runs a SELECT statement on tblPersons, I want the field to return only the PersonShift records for that person based upon the PersonDate. Each of the fields on my report have a CalendarDate field, and I want the SELECT statement to return records where the PersonDate matches the CalendarDate, and again, it should only display PersonShift records.
I am trying, and failing quite spectacularly to create a single query that will contain multiple expressions on the same field.
Please see attached jpg for example.
SQL: SELECT Count(StockData.status) AS FaultyPCs FROM StockData HAVING (([StockData].[Status] In ("Waiting Repair") And [StockData].[DeviceType] In ("Thick PC")));
What I want to be able to do is then add additional expressions to filter and count in the same way for "Thin PC" "Thin Laptops" "Thick Laptops" and so on.
But when I add one of these expressions to the next column in the builder, it seems to apply itself to the expression to it's left, causing that one to now give a result of 0.
Is there a way of separating one from another or do I have to create a separate query for each expression and then use another query to pull them all together (as I have done in another situations - but this will involve creating probably 20 separate queries.
For each record in my database, there are observation periods which are recorded in the format dd/mm/yyyy hh:mm:ss, titles as follows
1st Obs Start 1st Obs End 2nd Obs Start 2nd Obs End 3rd Obs Start 3rd Obs End.
I have been asked to create a query that will quickly show how many obervation periods commenced in a particular month. What I am trying to do is create a column that will be named Obs Start, and another, Obs End. For each record ID, this would then show as follows:
tblSFDC (contact information) includes CustID (primary key) and a memo field "Notes"
tblTheCall (call information) includes CustID (relates to tblSFDC) and "activity data fields" ie "Live", Left Message" , Sent email".
tblTheCall may in some cases have multiple records for each CustID
I need to : Concatenate from tblTheCall Field Names and field values (that are not null) Insert into tblSFDC.Notes Where tblTheCall.CustID = tblSFDC.CustID
I have a tabbed form that contains multiple rows of data just like the following: (it's a service checklist for a store where the user makes choices from the combo boxes: e.g. good, fair, poor, etc)
Since the combo boxes describe data that relates only to that element I can't put all the data needed into a single table. There are 40 of these rows so does that mean I have to create 40 tables? If so, how do I add the data to them from the form? Any help with this problem would be greatly appreciated!
My question is this: I am creating a database for a student survey. Some of the questions may have multiple answers. For instance, question 2 reads: "What location/time are you taking courses (select all that apply)"
and the possible answers are: 1)Daytime/Oakland 2)Evening/Oakland 3)Saturday College 4)BC
- Where a student could be taking classes at multiple locations or times. I am completely lost as to how to set this up. I have tried to set the properties for the field on the form to accept multiple responses, but of course, these do not save to the table and so it's completely useless.
I have question regarding multiple choices fields. I would like to store constrained but multiple values in a single field. I used the assistant to create the multiple choice field in the table, but I'd like to have it displayed in my form with check boxes (more readable in my tabular form) instead of drop down list. Is it possible ...
I have set up a parameter query in Access 2003 that asks the user for the "Section", such as "Admin", "Accounting" etc.
I need them to be able to respond to the prompt with more than one section if they want- sometimes just one, sometimes two or three or four.
So they can get "Accounting" and "Admin" both in the records that are returned.
The code: SELECT T_ElainesMaster.Section, T_ElainesMaster.Login, T_ElainesMaster.Workstation, T_ElainesMaster.NT, T_ElainesMaster.Barcode, T_ElainesMaster.[PC model], T_ElainesMaster.[Emp Name], T_ElainesMaster.[swap or not], T_ElainesMaster.[Exp Date] FROM T_ElainesMaster WHERE (((T_ElainesMaster.Section) Like [What section would you like to include?])) ORDER BY T_ElainesMaster.Section;
I have a query that displays all records. I need it to limit based on multiple criteria in a single field. I.E... instead of all employees from every section, I just want it to display employees from section A, C, D, F one time and next time maybe go with section B, C, D. For some reason the solution eludes my little brain.
A user wanted to key in the data in a single form where she can select where a particular procedure is located. The procedure could be duplicated and placed in a few departments.
My tables are as follows:- tbl_Proc_Dept:- ProcNo - Text (Primary) TrgConducted - Yes/No DeptAbbv - Text (Primary)
tbl_Dept:- DeptAbbv:- Text (Primary) DeptDetails:- Text
I created a form where i have the following fields in the form:- 1. ProcedureNo - Text 2. TrgConducted - CheckBox 3. MainDept- ComboBox (DeptAbbv data field) 4. Finance – CheckBox (DeptAbbv data field?) 5. Admin – CheckBox (DeptAbbv data field?) 6. Purchasing – CheckBox (DeptAbbv data field?) 7. Facilities – CheckBox (DeptAbbv data field?) 8. MIS – CheckBox (DeptAbbv data field?)
How can I add multiple deptabbv field in a single form?
Hi, this question is more about Microsoft Access than it is about ASP. However it involves a database that I am setting up for a website being written in ASP.
I have a table which is going to store business details. Every business belongs to a business category and related subcategory. For example Garages and MOT Centre.
I want to store up to 5 categories for each business. Is it possible to link to the categories and subcategories tables for each of the 5 category fields in the business table?
I am facing an issue with an access table.I have a field named "Contact Dates" , supposedly that field will store in a drop down list all the dates that the contact with the related company was made, how can I store it ? I am using in the current moment a memo data type to store the data and a comma for splitting them. How to create a drop down list for storing and displaying all the recorded dates and recording all the new data values as date format.