object.DataSource.SQL [=value]
This property stores the main part of a query that retrieves data for the form. The main part usually includes the actual SQL command (SELECT), list of fields to be retrieved and a list of tables from which the data will be retrieved (FROM).
The SQL query is eventually built as concatenation of SQL, Where and Order properties.
To modify the SQL property (alter the SQL query), you should use the BeforeBuildSelect event procedure of the form.
firstname
and lastname
) into the name
field is not recognized
by the standard of SQL language (here it is used for Access database only).
customers.DataSource.SQL = "SELECT customer_id, (firstname & ' ' & lastname) AS name, city FROM customers"