(14)N and (17)O nuclear quadrupole resonance frequencies have been measured in 1:1 cocrystals and salts of 2-amino-4,6-dimethylpyrimidine and several carboxylic acids. A systematic decrease of the (17)O quadrupole coupling constant on increasing strength of the hydrogen bond is observed in cocrystals bound by O-H···N hydrogen bonds. The O-H distances deduced from the line widths of the (17)O NQR lines show that the hydrogen atom is in a hydrogen bond formed by a carboxylic groups for about 0.01 nm displaced from the oxygen atom toward the center of the hydrogen bond. In the O-H···N hydrogen bond formed by the hydroxyl group, which is only slightly longer than the hydrogen bonds formed by the carboxyl group, the hydrogen atom is much less displaced. A linear relation between the (14)N quadrupole coupling constant and the sum of the inverse third powers of the H···A (A = O or N) distances is deduced for the amino group. A linear correlation of the principal values of the (14)N quadrupole coupling tensor in -NH2, as observed in the solid phase and in the gas phase, is analyzed in a simple model assuming a displacement of the electron charge in the N-H σ bond and simultaneous deformation of the nitrogen lone pair electron orbital. At the ring nitrogen position, hydrogen bonding and proton transfer produce a large decrease of the (14)N quadrupole coupling constant. A linear correlation of the principal values of the (14)N quadrupole coupling tensor is observed in cocrystals and salts of 2-amino-4,6-dimethylpyrimidine. This correlation differs from the correlation observed in substituted pyrimidine, where the hydrogen atoms are replaced by other atoms or functional groups. The difference is analyzed in a model, which assumes that the hydrogen bonding and substituents affect the nitrogen lone pair and π electron orbitals. The analysis shows that the two effects are nearly independent.