Process a Cube

A database, shared dimensions and their levels, and a cube and its measures are now in place and the cube can be processed.

Add a final command button to the form named cmdProcess. Add the following code to the cmdProcess_Click() event:

Private Sub cmdProcess_Click()

    Dim strDBName As String

    Dim strCubeName As String

    Dim bResponse As VbMsgBoxResult

    

    'Do we have a database?

    If dsoDB Is Nothing Then

        strDBName = InputBox("Enter name of Database with cube to process.", "Process Cube")

        If strDBName = "" Then

            MsgBox ("You must enter the name of a Database")

            Exit Sub

        End If

        

        If Not dsoServer.MDStores.Find(strDBName) Then

            MsgBox (strDBName & " database not found on this server")

            Exit Sub

        Else

            Set dsoDB = dsoServer.MDStores(strDBName)

        End If

    End If

   

    'Does the Database have an attached Datasource?

    If dsoDB.DataSources.Count = 0 Then

        MsgBox ("Please attach a Datasource")

        Exit Sub

    End If

    

    'Do we have Dimensions and Levels?

    If dsoDB.Dimensions.Count = 0 Then

        MsgBox ("Please add Dimensions and Levels to Database")

        Exit Sub

    End If

    

   'Do we have a cube?

   If dsoCube Is Nothing Then

        strCubeName = InputBox("Enter the name of the cube to process.", "Process Cube")

        If strCubeName = "" Then

            MsgBox ("You must enter the name of a cube to process")

            Exit Sub

        End If

        

        If Not dsoDB.MDStores.Find(strCubeName) Then

            MsgBox (strCubeName & " cube not found in this database")

            Exit Sub

        Else

            Set dsoCube = dsoDB.MDStores(strCubeName)

        End If

        

    End If

 

    'Does cube have measures?

    If dsoCube.Measures.Count = 0 Then

        MsgBox ("Please add Measures to cube")

        Exit Sub

    End If

    

    'Everything should be in place for processing the cube

    bResponse = MsgBox("Processing Cube may take some time - Proceed?", _

    vbYesNo, "Process Cube")

    If bResponse = vbYes Then

        dsoCube.Process

        MsgBox ("Complete - Use OLAP Manager to browse data")

    End If

    

    Exit Sub

ProcessCube_Err:

    Debug.Print "An error occurred processing the cube"

    Debug.Print Err.Number, Err.Description, Err.Source

    Err.Clear

End Sub

Save your project and run the application. Click Process. You may be prompted for the name of the database and cube to process. Enter the name of the database and cube you created in the previous steps.

Processing the cube can take several minutes. You can view the cube data using the OLAP Manager after processing is complete.

(c) 1988-1998 Microsoft Corporation. All Rights Reserved.