Access Report Bold if meet condition.

georg0307

Registered User.
Local time
Today, 19:10
Joined
Sep 11, 2014
Messages
91
Hi All, I have a special issue with Access 2007, that I cannot solve. I have a report with 2 fields: Ingredients and Allergens. I need to obtain a TextBox with Ingredients, Comma separeted and if Allergen is not equal to "Null" the ingredient must be Bold. here an example:

The data are:

Ingredients Allergens
water
sugar Sugar
glucose syrup (corn) Sugar
lemon juice (4%)

Result in TexBox must be:
water, sugar, glucose syrup (corn), lemon juice (4%).

In this moment I am using GetList Function (see the Bottom of my Thread) but I am in difficult to make Bold if Allergen is present.

Thanks in advance.

Option Compare Database
Option Explicit

Public Function GetList(SQL As String _
, Optional ColumnDelimeter As String = ", " _
, Optional RowDelimeter As String = vbCrLf) As String
'PURPOSE: to return a combined string from the passed query
'ARGS:
' 1. SQL is a valid Select statement
' 2. ColumnDelimiter is the character(s) that separate each column
' 3. RowDelimiter is the character(s) that separate each row
'RETURN VAL: Concatenated list
'DESIGN NOTES:
'EXAMPLE CALL: =GetList("Select Col1,Col2 From Table1 Where Table1.Key = " & OuterTable.Key)

Const PROCNAME = "GetList"
Const adClipString = 2
Dim oConn As ADODB.Connection
Dim oRS As ADODB.Recordset
Dim sResult As String

On Error GoTo ProcErr

Set oConn = CurrentProject.Connection
Set oRS = oConn.Execute(SQL)

sResult = oRS.GetString(adClipString, -1, ColumnDelimeter, RowDelimeter)

If Right(sResult, Len(RowDelimeter)) = RowDelimeter Then
sResult = Mid$(sResult, 1, Len(sResult) - Len(RowDelimeter))
End If

GetList = sResult
oRS.Close
oConn.Close

Cleanup:
Set oRS = Nothing
Set oConn = Nothing

Exit Function
ProcErr:
' insert error handler
Resume Cleanup

End Function
 
You have to use HTML code for that, (<strong> or <b>).
water, <b>sugar</b>, <b>glucose syrup (corn)</b>, lemon juice
Or
water, <strong>sugar</strong>, <strong>glucose syrup (corn)</strong>, lemon juice
And the Text control property = "Text Format" property must be = "Rich Text".
 
Hi,
thanks for prompt reply but the problem is that GetList function collect and group all records in one field with all ingredients comma separeted. And after this I cannot apply the condition "if allergen" is present to make it bold. Sorry if my english is not so good i am Italian........
 
Then you need to build you own function if you can't expand what you have now!
 
Ciao, thanks again for your suggestion, I'm not really able to build a function that performs this operation THIS is the reason why I am asking help. However, in the query expression from which I get the comma-separated list is the following:

Ingredients: (GetList("Select ingrediente_eng From QuerySchedaTecnicaOrdIngr As T1 Where T1.ART = """ & [QuerySchedaTecnicaOrdIngr].[ART] & """";"";", ")) & "."

I miss the part that makes Ingredients the font bold "IF ALLERGEN <>".
This problem is causing me a big headache.....
 
Then post your database with some sample data + info from where you run the query, and in which form/report the text control for the returned result is!
Zip your database because you haven't post 10 post yet.
 
Ok,
I had to reduce the DB dimension in order to upload it.

The report involved in my question is "ReportSchedaTecnicaItalia" that have origin from the query "QueryScheda_Tecnica".

The TextBox involved is "Ingredienti" that is generate by the following expression that refers to "GetList" function:

Ingredienti: (GetList("Select ingrediente_ita & ID_elencoing From QuerySchedaTecnicaOrdIngr As T1 Where T1.ART = """ & [QuerySchedaTecnicaOrdIngr].[ART] & """";"";", ")) & "."

In attachment there is the complete database.
 

Attachments

Could you please explain again what you want to do, because when I look at the data I can't get it, (in plain English, no MS-Access jargon)?
Sample data in the field Ingredienti:
acqua1, zucchero2, sciroppo di glucosio (mais)3, succo di limone (4%)4, sciroppo di glucosio-fruttosio (mais)5, olio di cocco6, latte scremato in polvere7, proteine del latte8, LATTOSIO9, acidificante: acido citrico10, emulsionanti: mono- e digliceridi degli acidi grassi e sucresteri degli acidi grassi11, addensanti: alginato di
In field Ingredients:
water, sugar, glucose syrup (corn), lemon juice (4%), glucose-fructose syrup (corn), coconut oil, skimmed milk powder, milk proteins, LACTOSE, citric acid, emulsifiers: mono- and diglycerides of fatty acids and sucrose esters of fatty acids, thickeners: propylene glycol alginate, carob seed flour and guar gum, aromas.
There er NO field in it with the name Allergens. The closed is Allergeni_Tutti and it has only one value = "Latte."
 
Ciao,

thanks again for reply. In the word document attached, I hope to have explained better.
;)
 
And where is the Word document? :confused:
 
Look at the code in function GetListJHB. :)
 

Users who are viewing this thread

Back
Top Bottom