The use of DataCombo and DataList controls in VB (Ii.)

Source: Internet
Author: User

Create a simple DataCombo application
The following example uses the DataCombo control to create a data entry interface for the titles table of the Northwind.mdb sample database. This input interface enables users to enter new products and assigns them to existing vendors by providing a lookup table that includes all vendor names. When users enter the value of a vendor field in the input form, they can select a vendor from a list box. When they select a vendor, the vendor's SupplierID field value is copied to the SupplierID field in the Products table.
To use the DataCombo control to create a lookup table
1. Create an OLE DB data source for the Northwind database. If you have not yet created a data source, follow the steps in "Creating an OLE DB data source for Northwind."
2. Create a new standard EXE project in Visual Basic. If the DataGrid, DataCombo, or ADO Data control is not in the Toolbox, right-click the Toolbox, and then use the Parts dialog box to add the control.
3. Add a DataCombo control, two ADO data controls, and a DataGrid control to the form. 4. In the Properties window, set the properties of the first Data Control (ADODC1) as shown in the following table.
4. In the Properties window, set the properties of the first Data Control (ADODC1) as shown in the following table.

5. In the Properties window, set the properties of the second Data Control (ADODC2) as shown in the following table.

6. In the Properties window, set the properties of the DataGrid control as shown in the following table.

7. In the Properties window, set the properties of the DataCombo control as shown in the following table.

8. Finally, add the following code to the form's code module:
Private Sub Form_Load ()
' Hides the SupplierID field in the DataGrid control so that the user
' doesn't confuse which value to change.
Grdproducts.columns ("SupplierID"). Visible = False
End Sub
9. Run the project.
You can browse through the recordset by clicking the arrows on the visual ADO Data control. If you do this, the DataCombo control updates and displays the name of the vendor for each product. If you want to edit the SupplierID field, click the arrow for the DataCombo control to display a Drop-down list, and then click a different vendor to change the value written to the SupplierID field.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.