Dynamically set up a data source with the RecordSource property of a form
Source: Internet
Author: User
The form, report object in Access has the RecordSource property, is a string literal, read-write, describes the dataset associated with these objects, can be set dynamically in the program's run, its value can be a table name, query name, and SQL statement, and it is much easier to use. Like what:
For form MyForm, you can use SQL to set a dataset in a module inside of it:
Dim strSQL as String
strSQL = "SELECT * from Myqurrey Where addrss= ' Sichuan '"
me! RecordSource = strSQL
The following directly sets the MyForm form's data source to table customer by using the Forms collection externally:
forms! Myform.recordsource= "Customer"
The following example dynamically sets the data set for a subform mysubform in a form:
me! MySubForm.Form.RecordSource = "SELECT * from notebook WHERE date= '" +me!focusdate+ ""
Note that when referencing the RecordSource property of a subform, you must add a form keyword to the main form to know that the object is a form before it can reference its RecordSource property.
For these properties, if the memory is not clear, Access2003 in the program will automatically pop-up prompts, you can use these tips to smooth programming.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.