Team Bytes,
I have a query that is outputting a few duplicate records because of two fields, [HR Reporting].[Type of Occupational Cert] and [HR reporting].[Date Occupational Cert Issued]. I would like to output one record with the multiple certifications and dates concatenated in one field. Example of current output:
Name Certs Cert Date
Doe Jane CISSP 1/2/03 (the rest of the fields are the same)
Doe Jane SEC+ 2/3/04
Doe Jarl C++ 3/4/05
Doe John Net+ 4/5/06
Would like to display:
Name Certs And Dates
Doe Jane CISSP 1/2/03; SEC+ 2/3/04; (the rest of the fields)
Doe Jarl C++ 3/4/05
Doe John Net+ 4/5/06
Would anyone be able to give an example chunk of VBA code to make this work?
Please let me know if you have questions or require additional information and as always, thank you for your valuable time/effort.
Mike
4 1075
Probably the best way to do this is to use a User-Defined Function that concatenate those fields into one. If you do a search on this forum for “MS Access VBA Concatenate” you may be able to find several that are useful. I couldn’t find the exact specific one I was looking for, but there are several that can point you in the right direction.
Hope this hepps!
NeoPa 32,556
Expert Mod 16PB - Placing a Full Name in a Field called [Name] is wrong for so many reasons, but that is probably a Topic for discussion at another time.
- Sample Data used in Demo:
-
ID TName Certs Cert Date
-
1 Doe Jane CISSP 1 /2 /2003
-
2 Doe Jane SEC+ 2 /3 /2004
-
3 Doe Jarl C++ 3 /4 /2005
-
4 Doe John NET+ 4 /5 /2006
-
5 Doe Jane MCSE 6 /23/2007
-
6 Doe Jarl PAER 12/12/2008
-
7 Flintstone Fred
-
- Create the following Query which will list all 'UNIQUE' Names sorted alphabetically and call a Function within a Calculated Field:
-
SELECT DISTINCT tblData.TName AS Employee_Name, fConcat([TName]) AS Certification
-
FROM tblData
-
ORDER BY fConcat([TName]);
-
- Function Definition:
-
Public Function fConcat(strName As String) As String
-
Dim MyDB As DAO.Database
-
Dim rstConcat As DAO.Recordset
-
Dim strBuild As String
-
-
Set MyDB = CurrentDb
-
-
Set rstConcat = MyDB.OpenRecordset("SELECT * FROM tblDATA WHERE [TName] = '" & strName & "'", dbOpenForwardOnly)
-
-
With rstConcat
-
Do While Not rstConcat.EOF
-
strBuild = strBuild & ![Certs] & " " & ![Cert Date] & ";"
-
Debug.Print ![TName]
-
.MoveNext
-
Loop
-
End With
-
-
fConcat = Left$(strBuild, Len(strBuild) - 1)
-
-
rstConcat.Close
-
Set rstConcat = Nothing
-
End Function
-
- Results after Query Execution:
-
Employee_Name Certification
-
Flintstone Fred
-
Doe Jarl C++ 3/4/2005;PAER 12/12/2008
-
Doe Jane CISSP 1/2/2003;SEC+ 2/3/2004;MCSE 6/23/2007
-
Doe John NET+ 4/5/2006
-
- Look at the Attachment, and should you have any questions feel free to ask.
Thank you all for your quick replies! I can't open the demo.zip at work, but I will give this a try, thanks!
Mike
Sign in to post your reply or Sign up for a free account.
Similar topics
by: G Kannan |
last post by:
Hey all!
I have written a perl script to retrieve information from a HTML Form
and insert the data into an Oracle database table. I am gettting the
the following error message:
"Use of...
|
by: B Love |
last post by:
I just need a small mod to my code (I think) to get the result I want.
Earlier this week I had received help from FredG on concatenating a field in
a form. I went on to create a field in the form...
|
by: michael.casey |
last post by:
The purpose of this post is to obtain the communities opinion of the
usefulness, efficiency, and most importantly the correctness of this
small piece of code. I thank everyone in advance for your...
|
by: Ron |
last post by:
Hello,
I have to concatenate some large strings which end up in a
text file. I am just checking if the StringBuilder class
can improve what I am currently doing - and how to
implement this. ...
|
by: Larry Hastings |
last post by:
This is such a long posting that I've broken it out into sections.
Note that while developing this patch I discovered a Subtle Bug
in CPython, which I have discussed in its own section below.
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |