Using Query by typing " SELECT......"

F

Frank Situmorang

Hello,

When I saw on the addresss sample database, the form Household is uing query
by just mentioning SELECT......

My question is how can type SELECT then prompt the table to us. I normally
use grid query, what is the difference using grid query of SQL Query ( is it
SQL that using SELECT....?)

Many thanks for any idea provided
 
A

Allen Browne

The RecordSource property of a form can accept:
- a table name
- a query name
- a SQL statement.

You can change the RecordSource property of the form programmatically. For
example, if the form currently has a RecordSource of:
SELECT Table1.* FROM Table1;
you could do this in the Open event procedure of your form:
Dim strSql As String
strSql = "SELECT Table2.* FROM Table2;"
Me.RecordSource = strSql
That's assuming Table1 and Table2 have identical fields (same names, and
same data types.) Some versions of Access will just crash if a field
suddenly disappears or changes data type.

If you do have several tables with the same fields, you have not built a
relational database. Most likely, those tables should be combined into one
table, with an extra field to indicate the category (i.e. whatever reason
you currentlly have them in different tables.)
 
R

Robert

Click on the Record Source property. Then click on the ... (3 dots) over to
the right of the records source property. This should bring up a query
grid. To switch to SQL code, click View/ SQL View. You can make your query
in Design View or SQL View. When you have finished making the query, do not
save it. Click on the X instead. Then click Yes on the popup.

Robert
 
Top