Public Function getTradeMarks(varProdName As Variant) As String
Dim rs As DAO.Recordset
Dim intRecords As Integer
Dim strTradeMarks As String
Dim strSql As String
'strSql = "Select distinct [trademark] from tblTrademarks where [productName] = " & varProdName
strSql = "Select distinct [trademark] from tblTrademarks where [productName] = '" & varProdName & "'"
Set rs = CurrentDb.OpenRecordset(strSql, dbOpenDynaset)
Do While Not rs.EOF
intRecords = intRecords + 1
If rs.AbsolutePosition = 0 Then
strTradeMarks = rs.Fields("trademark")
strTradeMarks = strTradeMarks & ", " & rs.Fields("trademark")
If intRecords = 1 Then
strTradeMarks = strTradeMarks & " is a registered trademark of company " & varProdName
strTradeMarks = Left(strTradeMarks, InStrRev(strTradeMarks, ",") - 1) & " and" & Mid(strTradeMarks, InStrRev(strTradeMarks, ",") + 1) & " are registered trademarks of " & varProdName
getTradeMarks = strTradeMarks
123 T1, T2, T3 and T6 are registered trademarks of 123
234 T1 and T4 are registered trademarks of 234
456 T7 is a registered trademark of company 456
789 T8 is a registered trademark of company 789
The above code works Excellent.
I am looking for some code like this , my situation is similar but it has another column
For example In reference to the same example above I have one more column
Dose anyone know how to adjust the above code to get the following output
We can help you where you get stuck, but I doubt anyone here is going to just do the work for you.... I guess someone might... but I won't because it makes me think I am doing your job/homework for you.
If it was me, I'd just scrap the existing code and start again only using fragments and concepts from the existing code. I personally find it quicker than having to modify existing code to suit new requirements... especially if I didn't write the code in the first place.