BusinessObjects Board

VBA to duplicate a DataProvider, stopped by QP0007

In a fit of hutzpah and irritation I decided to write a macro to copy a DataProvider. The code looks convincing so far,but stops with the famous QPA0007

on the .SQL = d.SQL statement. There is probably a great deal more required, but I cannot dig enough out of the web to pin down the details. I would be grateful for any help.


Public Sub TestTheBrute()
    Call CopyDataProvider("Query 1 with OP_v2", "Copy")
End Sub

Public Sub CopyDataProvider(InName, OutName)

    Dim d As DataProvider
    Dim q As DataProvider
    
    Set d = FindDataProvider(InName)
    If d Is Nothing Then Exit Sub
    
    Set q = FindDataProvider(OutName)
    If q Is Nothing Then
        Set q = ActiveDocument.DataProviders.AddQueryTechnique( _
            d.Universe.LongName)
    End If
    
    With q
        .Name = OutName
        [b]SQL = d.SQL[/b] 
   End With
   
End Sub

Public Function FindDataProvider(InName) As DataProvider
    For Each d In ActiveDocument.DataProviders
        If StrComp(d.Name, InName, vbTextCompare) = 0 Then
            Set FindDataProvider = d
            Exit Function
        End If
    Next d
    Set FindDataProvider = Nothing
End Function

obsolent (BOB member since 2004-10-05)

Why not look at the Download section in BOB, there is a macro “Copy Data Providers / Copy Report Variables” already :mrgreen:

Topic moved to SDK forum.


Andreas :de: (BOB member since 2002-06-20)

Many thanks for your download - an absolute treasure trove - a great reward for trying to reinvent the wheel!


obsolent (BOB member since 2004-10-05)