We investigate the connection between the vertical structure of stellar discs and the formation of bars using high-resolution simulations of galaxies in isolation and in the cosmological context. In particular, we simulate a suite of isolated galaxy models that have the same Toomre Q parameter and swing amplification parameter but that differ in the vertical scale height and velocity dispersion. We find that the onset of bar formation occurs more slowly in models with thicker discs. Moreover, thicker discs and also discs evolved in simulations with larger force softening also appear to be more resilient to buckling, which acts to regulate the length and strength of bars. We also simulate disc-halo systems in the cosmological environment using a disc-insertion technique developed in a previous paper. In this case, bar formation is driven by the stochastic effects of a triaxial halo and subhalo-disc interactions and the initial growth of bars appears to be relatively insensitive to the thickness of the disc. On the other hand, thin discs in cosmological halos do appear to be more susceptible to buckling than thick ones and therefore bar strength correlates with disc thickness as in the isolated case. More to the point, one can form discs in cosmological simulations with relatively weak bars or no bars at all provided the discs as thin as the discs we observe and the softening length is smaller than the disc scale height.