If you have copy of Access, or the Microsoft database generator in VB
2008 ( SQL SERVER or whatever ) try using the design wizard to generate the S.Q.L. then copy and paste it into the program at the appropriate point. Make sure it generates the desired output in the wizard firstly. Sometimes there are slight differences in the syntax of S.Q.L. commands as expected, and that which works e.g. '%' has now replaced '*' as a 'wild-card' character when using the LIKE clause in S.Q.L. Good luck, if anything's not clear, reply to this.