The balance between molecule-molecule and molecule-surface interactions is a determining factor in the creation of well-ordered organic networks formed by self-assembly on crystalline metal surfaces. We have used a scanning tunneling microscope under ultrahigh vacuum conditions to study the molecular self-assembly of trimesic acid on a surface that is modulated on a comparable nanometer scale as the size of the molecules. This is made of one layer of silver grown on a Cu(111) surface where it forms a periodic reconstruction. It is shown that the self-assembly of trimesic acid at room temperature, where intermolecular interactions are taking place via hydrogen bonds, is strongly disturbed due to the modulated substrate and the spatially varying potential imposed on the molecules. Annealing to 350 K partly deprotonates the molecules and changes the intermolecular interactions to stronger ionic hydrogen bonds. This reduces the influence of the modulated substrate and allows the molecules to self-assemble into long-range ordered networks on the surface. Comparisons are made to self-assembly on the flat surfaces of Ag(111) and Cu(111), where we always find well-ordered molecular networks.