This example shows how to retrieve the information for employees whose first names start with “AN” from table Employees on the same Database Exchange object,
To use an SQL statement as a data source:
SELECT *FROM Employees WHERE FirstName LIKE ‘AN%
You also can change Record Source at runtime to display different records. The following example shows how to change SQL statement at runtime.
To change SQL statements at runtime:
FUNCTION
UpdateRecordSource(STRING
sRecordSource)
_ObjectSetProperty(ObjectByName("AN35"), "
RecordSource1", sRecordSource);
END
UpdateRecordSource(SQL_RECORDSOURCE)
SELECT * FROM Employees WHERE FirstName LIKE 'M%'
The result lists two employees whose first name starts with “M”, as shown here. Be aware that method Refresh is not required if the command type is not a stored procedure as the control will automatically refresh data internally.