BusinessObjects Board

Removing and adding of Condition through VBA

Removing and adding of Condition through VBA
Description I am try to Remove and adding of Condition through VBA to Universe Dataprovider.
I have 2 conditions and 3rd condition is for dynamic
through VBA
when I try to refresh the document it is prompting me the 2 condition with prompt in the same dataprovider for every line of code in VBA.

Dim doc As Document
Dim DPs As DataProviders
Dim dp As DataProvider
Dim dp1 As DataProvider
Dim dp2 As DataProvider
Dim dp3 As DataProvider
Dim dp4 As DataProvider
Set DPs = Application.ActiveDocument.DataProviders

Set dp = DPs.Item(“Pre LY CPIPOSTA”)
dp.Load
dp.Queries.Item(1).Conditions.Remove (3)
dp.Queries.Item(1).Conditions.Add “Fct Measures”, “Period_Id”, “BETWEEN”, LY_pre_start_per_id, “Constant”, LY_pre_end_per_id, “Constant”
dp.Unload
Set dp1 = DPs.Item(“Post LY CPIPOSTA”)
dp1.Load
dp1.Queries.Item(1).Conditions.Remove (3)
dp1.Queries.Item(1).Conditions.Add “Fct Measures”, “Period_Id”, “BETWEEN”, LY_pre_start_per_id, “Constant”, LY_post_end_per_id, “Constant”
dp1.Unload

Please can u help in this issue.


Bharath (BOB member since 2004-06-12)

You can try adding Application.Interactive = False at the beginning and Application.Interactive = True at the end of the code.


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)

Why not do this through the data base? Build some view that returns the dates you want so that you don’t have to mess with VBA. When I tried adding and deleting conditions through VBA, it was SSLLOOOOOOWW and it really screwed up the organization of the objects in the Conditions box.


Dennis W. Disney :us: (BOB member since 2003-09-17)

[quote:4249666d69=“Dennis W. Disney”]Why not do this through the data base? Build some view that returns the dates you want so that you don’t have to mess with VBA. When I tried adding and deleting conditions through VBA, it was SSLLOOOOOOWW and it really screwed up the organization of the objects in the Conditions box.
[/quote]

Dennis, when things were so slow, were you using the dp.Load method? It speeds things up tremendously.


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)

Dennis, when things were so slow, were you using the dp.Load method? It speeds things up tremendously.
[/quote]
Actually, I shouldn’t have said “I tried”. On one project, we had a consultant write some VBA code for migrating reports from one repository (e.g. Development) to another (e.g. UAT). The macro pulled the report down and repointed it to the new universe domain. Because you can’t purge data providers through the SDK, the consultant’s idea was to add a condition that would always fail to each data provider, refresh the data provider (which would return no data), then remove the condition. The macro ran fine until it started messing with the conditions and then it crawled. I was asked to look at it as I had also done some VBA macros. The code looked fine to me and I believe he loaded and unloaded the data providers. I don’t remember if the adding or deleting the condition was the problem.

Regardless, the organization of the conditions after the adding and removal was unacceptable, so we figured out prompt values that would always return no data and used those to refresh the data providers. And we all lived happily ever after…


Dennis W. Disney :us: (BOB member since 2003-09-17)

Interesting. By the way, I did have a method for purging data providers. Invoke the dp.Edit method after a SendKeys “%s%y” (I think that’s it). It would do a “save and close” and answer “yes” to the purge question. Unfortunately BusObj removed the shortcut keys in v5.1.7, so that trick stopped working. I haven’t tried 5.1.8 or later to see if the shortcut keys have returned.


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)

Dennis:

Do you know if there is code available here that will re-point reports to a new universe (like promoting a report from dev->uat->production) like you mentioned above? I looked around awhile for something like this and I didn’t see anything. Thanks.

Rob


rhoehn (BOB member since 2003-12-10)

Did you check out this BOB download?


Dennis W. Disney :us: (BOB member since 2003-09-17)

Thanks Dennis, I don’t know how I missed that :wink:

Rob


rhoehn (BOB member since 2003-12-10)