PDA

Click to See Complete Forum and Search --> : ADO controls and SQL


gilly
Jun 12th, 2000, 06:38 PM
If you are setting an ADO control's recordsource in runtime, can you have multiple where conditions?

eg.
If a database has two tables:
Forms (containing Title, Author, UpdateCode) and
UpdateDetails (containing UpdateCode, Surname)

Could you have a statement
"Select.... WHERE Forms.UpdateCode = UpdateDetails.UpdateCode, AND (TITLE = 'Quality Form' OR Surname = 'Bloggs')"

Is this possible and if so, what is the syntax to set the recordset??????

Ianpbaker
Jun 12th, 2000, 07:07 PM
Hi Gilly

Yes you can do that, but you will need a common field that is in both tables (like updatecode in your example). You then need to do a join to get the information back. use the following code to achieve this.

SELECT ... FROM Forms as frm INNER JOIN UpdateDetails as upd on(frm.updatecode=upd.updatecode) WHERE ..

In the select part you can select any fields from either table using their alias (frm for form and ups for update details) eg. Select frm.updatecode,upd.*.

And in the where statement you can have frm.TITLE = 'Quality Form' OR upd.Surname = 'Bloggs'

Hope this helps

Ian