The dense cloud associated with W40, which is one of the nearby H ii regions, has been studied in millimetre-wave molecular lines and in the 1.2-mm continuum. Moreover, 1280- and 610-MHz interferometric observations have been carried out. The cloud has a complex morphological and kinematical structure, including a clumpy dust ring and an extended dense core. The ring has probably been formed by the 'collect and collapse' process as a result of the expansion of the neighbouring H ii region. Nine dust clumps in the ring have been deconvolved. Their sizes, masses and peak hydrogen column densities are similar to 0.02-0.11 pc, similar to 0.4-8.1 M-circle dot and similar to(2.5-11) x 10(22) cm(-2), respectively. Molecular lines are obs...