SQL Access

Speaker Notes

Slide 1:

Please check information on SQL from other sources.

Slide 2:

At the Record Source for the ADO Contro click on ... to bring up the Property Pages as shown above.

Slide 3:

You need to change to 1 adCmdText and deactivate Table or stored procedure name as Donor2000 - you can delete it or have it deactivated when you switch to adCmdText.

select * means to select all fields and all records. I am only showing 3 fields so that is all that will appear

from gives the name of the table that is being used.

Slide 4:

All five records are now available because

Select * from donor2000

means select all records.

Slide 5:

This select is looking for all records where DCity = Fall River or Braintree.

Slide 6:

These are the only two records on the database that meet the criteria.

Slide 7:

After the SQL code was keyed in, it appeared in the record source.

Slide 8:

Note that only one record met the criteria of DrYrFirst > 1999 and Dcontact = Ann Smith. Note that these are string fields so the value you compare against is enclosed in quotes. This is not required for numeric data. Both conditions had to be true.

Slide 9:

The like used "19%" which means 19 followed by anything - a wildcard.

Slide 10:

Only these three are selected and they are in order by city so New Bedford is shown first, followed by Quincy, followed by Weymouth (alphabetic order by city). Note that this used city in the criteria even though city is not shown on the form. Error messages arise if you have fields on the form that will remain empty because of the select.