Creating a View

The process of creating an ADO View is the same as in DAO. To create a view in ADO:

1. Create a Catalog object and define its ActiveConnection property.

2. Create a Command object and define its CommandText property.

3. Append a new View object to the Views collection, using the Command object as its argument.

Dim cat As New ADOX.Catalog Dim cmd As New ADODB.Command

'Open the Catalog cat.ActiveConnection = CurrentProject.Connection

'Create the Command object that represents the View cmd.CommandText = "SELECT * FROM tblCustomers WHERE"

'Create the View

Cat.Views.Append "AllCustomers", cmd 'Clean up

Set cat.ActiveConnection = Nothing Set cat = Nothing Set cmd = Nothing

You might recall from the section on DAO QueryDefs that you could set the value of any parameters in code. In ADO, you set the parameter values in the Command object. We'll demonstrate this in the section Command Object.

0 0

Post a comment