Create a Single-valued Prompt Example

This example demonstrates how to create single-valued prompts in the context of creating a small model.
Sub Example33()
    Dim objTransApp As Object
    Dim model As Model
    Dim new_report As Report
    Dim new_query As Query
    Dim new_column As Column
    Dim new_prompt As Prompt
    objTransApp = CreateObject("IBMCognosTransformer.ApplicationCtrl.1")
    'Create a new model
    model = objTransApp.NewModel
    'Create a new report and add it to the model
    new_report = model.Reports.Add()
    new_report.Name = "Date Between List"
    new_report.Path = "/content/package[@name='GO Data Warehouse
(query)']" _
        & "/folder[@name='SDK Report Samples']" _
        & "/report[@name='Date Between List']"
    new_report.Update()
    'Create a new query and add it to the report
    new_query = new_report.Queries.Add()
    With new_query
        .Name = "Date Between List (Has Prompt)"
        .AutoSummary = False
        .MaximizeSpeed = True
        .SetsCurrentPeriod = True
        .Update()
    End With
    'Create 3 new columns and add them to the query
    new_column = new_query.Columns.Add()
    With new_column
        .Name = "Date"
        .OriginalName = "[Report].[Query1.0].[Date]"
        .Update()
    End With
    new_column = new_query.Columns.Add()
    With new_column
        .Name = "Order number"
        .OriginalName = "[Report].[Query1.0].[Order number]"
        .Update()
    End With
    new_column = new_query.Columns.Add()
    With new_column
        .Name = "Order method"
        .OriginalName = "[Report].[Query1.0].[Order method]"
        .Update()
    End With
    'Create 2 new Single-valued prompts and add them to the query
    new_prompt = new_query.Prompts.Add()
    With new_prompt
        .PromptValueType = xtrPromptValueType.trSingleValuePrompt
        .Name = "StartDate"
        .Type = "Date Time (1999-01-31 18:30:00)"
        .Value = "2005-01-01"
        .Update()
    End With
    new_prompt = new_query.Prompts.Add()
    With new_prompt
        .PromptValueType = xtrPromptValueType.trSingleValuePrompt
        .Name = "EndDate"
        .Type = "Date Time (1999-01-31 18:30:00)"
        .Value = "2006-12-31"
        .Update()
    End With
    'Save the model
    With model
        .SaveAs("GO Data Warehouse (query)X.mdl")
        .Close()
    End With
    objTransApp = Nothing
End Sub