We have a certain number of linked universes (they all have the same structures, and the same objects, the difference being how they get populated…)
Anyway, we have a set of reports which could be run for either of those universes, so we would like to be able to decide from a VB form which universe to choose and from there the Dataprovider would be refreshed.
I have built the VB form listing all the Universes available.
I can then edit the Dp for the given report, but it seems that the Universe name is Read only and I cannot update it.
Well I found it but it still returns an error.
This is the code:
Private Sub UserForm_initialize()
Set boDocs = Application.Documents
Set boDoc = ActiveDocument
Set boUnivs = Application.Universes
'Populates the DropDown Menu with the names of the available Universes
For Each boUniv In boUnivs
cmbUniverse.AddItem (boUniv.LongName)
Next
End Sub
'30 April 2003 (Olivier Masse)
Private Sub cmdChange_Click()
Dim i As Integer
Set boDocs = Application.Documents
Set boDoc = ActiveDocument
Set boDps = boDoc.DataProviders
iDps = boDps.Count
For i = 1 To iDps
Set boDp = boDps.Item (i)
boDp.ChangeUniverse (cmbUniverse.Value)
Next i
End Sub
When I run this code I get a message saying Object Required???
Shouldn’t the parameter to ChangeUniverse method be an Universe object. You seems to be passing a text string from the ComboBox. Try changing that to an Universe Object and check whether it works.
i have tried to change the string returned from the drop down menu but I still get an error message.
For i = 1 To iDps
For Each boUniv In boUnivs
If boUniv.LongName = cmbUniverse.Value Then
Set boUniv1 = boUniv
End If
Next
boDps.Item(i).ChangeUniverse (boUniv1)
Next i
According to the definition the function should be used as follow
Sri, it is because the repository wasn’t defined…
This code now works.
Dim i As Integer
Dim sDp As String
Dim newunivname As Universe
Set boDocs = Application.Documents
Set boDoc = ActiveDocument
Set boDps = boDoc.DataProviders
iDps = boDps.Count
For i = 1 To iDps
Set newunivname = Application.Universes(cmbUniverse.Value, "Repository Name")
boDps.Item(i).ChangeUniverse newunivname
Next i
Even more strange is the fact that it is the same code that I did yesterday. I thought of changing it after seeing message but instead ran it for once and worked great.
I am getting Type mismatch error when I try to change to universe of data provider from VB code. I am using BO 5.1.8 and the code is as follows:-
Public Function Refreshreport(reportname As String)
Dim ObjRep As New busobj.Application
Dim ObjDes As New Designer.Application
Dim ObjUniverse As Designer.Universe
Dim dp As busobj.DataProvider
Dim ObjReport As busobj.Document
Call ObjRep.LoginAs(“Parag”, , True)
Set ObjReport = ObjRep.Documents.Open(reportname)
Call ObjDes.LoginAs(“Parag”, , True)
Set ObjUniverse = ObjDes.Universes.Open(“D:\VB code POC\Test.unv”)
Set dp = ObjReport.DataProviders(1) Call dp.ChangeUniverse(ObjUniverse)
dp.refresh
End
I tried dp.ChangeUniverse ObjUniverse also.
I am relly frustated now bacuse of this error. Can any one suggest me the soluntion.
It is not necessary to involve the Designer SDK at all. There is essentially a subset of the Designer SDK contained within the Reporter SDK. In other words, there is a busobj.Universe object as well.
Change the Dim statement for ObjUniverse to busobj.Universe. Remove all of the Designer related code, and change the Set ObjUniverse line of code to something like this:
Set ObjUniverse = ObjRep.Universes("universe long name", "repository name (optional)")
{additional note … all of your other duplicate posts have been deleted}
Thanks a ton for your valuable suggestions. Just one more query… Set
ObjUniverse = ObjRep.Universes(“universe long name”, “repository name (optional)”) here instead of “Universe long name” is it possible to give universe path. I have temp universe stored on Local PC and I want to try with it.
And what exactly is universe long name ?
Very eagerly awaiting for your reply.
Thanks,
Parag
One more question.
Now it is giving me error “Multiple universes specify repository”.
Bascially where does it look for the universe when we give such “Long universe name?”
Is this the folder which we set from BO reporter by doing Tools->options->File Locations tab-> Universes??
If yes from VB, is it possible to change this path?
I have bit complex requirements so bugging you so much,
I guess it was a bit subtle, but the answers are in my previous posts. First, if you will keep the long name unique, you will not have that problem. If the long name is not unique, you can specify the repository as the second parameter. If the universe has not been exported, the repository is probably “.” …
I checked and what ever I said in my earlier post was correct. When ever you give long name of the universe it searches that universe in the directory which is mapped as universe directory i.e. Tools-> options-> documents tab-> universe.
We can change this directory from VB by using objRep.setBOdirectory
Thanks for all your inputs. Will bug you again if I get any more doubts.