ms-access

Ucase in Access report page header


I don't understand why the uppercase is not working in my header page control. I tried VBA code but the control is not activated. I tried the source control : =Ucase([Famille]) but the result is not changed I tried '>' in the format section, same result.

I'm missing something (I'm using Access 2019) ? Thanks for help. Vincent

edit : here is a screenshot (in French)enter image description here


Solution

  • The problem is most likely that your control (I assume that it is a TextBox) has the Name Famille. If you link it to the formula =UCase([Famille]), then [Famille] inside this formula refers to the TextBox instead of the data source field. This creates a recursion and confuses Access.

    Solution: Rename the TextBox to a Name differing from the data source field, e.g.: txtFamille, but keep the Control Source: =UCase([Famille]).

    Update (after you have posted an image)

    You are using a ComboBox (which you didn't mention is the question). There are different ways to parametrize it. But Famille might actually be a number corresponding to a family Id and the ComboBox would in this case look up the name from another table. In this case you cannot apply UCase() to Famille. Instead, you would have to apply it in the query used as Row Source of the ComboBox.

    E.g. (Row Source):

    SELECT Famille, UCase(Description) AS Titre
    FROM tblFamille
    ORDER BY UCase(Description)
    

    Btw., I am never using ComboBoxes in reports. They just don't look great. Instead I link the required information in the query used as Record Source of the Report and then display it in a TextBox. E.g.,:

    SELECT p.Nom, UCase(f.Description) AS Titre, ...
    FROM
        tblPlante p
        LEFT JOIN tblFamille f
            ON p.Famille = f.Famille
    ORDER BY ...
    

    It is also a good idea to use naming conventions that make understanding queries easier. E.g., if I have an entity Famille, the table is named tblFamille, the primary key column FamilleId and the description Famille. This makes it more obvious which column is the Id column.