The dense cloud associated with W40, one of the nearby H II regions, has been studied in millimeter-wave molecular lines and in 1.2 mm continuum. Besides, 1280 MHz and 610 MHz interferometric observations have been done. The cloud has complex morphological and kinematical structure, including a clumpy dust ring and an extended dense core. The ring is probably formed by the collect and collapse process due to the expansion of neighboring H II region. Nine dust clumps in the ring have been deconvolved. Their sizes, masses and peak hydrogen column densities are: $sim 0.02-0.11$ pc, $sim 0.4-8.1 M_{odot}$ and $sim (2.5-11)times 10^{22}$ cm$^{-2}$, respectively. Molecular lines are observed at two different velocities and have different spatial distributions implying strong chemical differentiation over the region. The CS abundance is enhanced towards the eastern dust clump 2, while the NH$_3$, N$_2$H$^+$, and H$^{13}$CO$^+$ abundances are enhanced towards the western clumps. HCN and HCO$^+$ do not correlate with the dust probably tracing the surrounding gas. Number densities derived towards selected positions are: $sim (0.3-3.2)times 10^6$ cm$^{-3}$. Two western clumps have kinetic temperatures 21 K and 16 K and are close to virial equilibrium. The eastern clumps 2 and 3 are more massive, have higher extent of turbulence and are probably more evolved than the western ones. They show asymmetric CS(2--1) line profiles due to infalling motions which is confirmed by model calculations. An interaction between ionized and neutral material is taking place in the vicinity of the eastern branch of the ring and probably trigger star formation.