Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help on VB to update APS INFOOBJECT

Status
Not open for further replies.

ronaldcs

MIS
Jun 21, 2002
3
US
Hi,

I'm creating a VB app that will update the picklist of an .rpt file, and then subsequently update the APS with the new .rpt.

My question is will the file index for the .rpt file always be 1 (see the line highlighted red below)? I'm wondering if it's OK to hard code the file index or whether I will need to search for the .rpt file in the Files collection...

Thanks,

rcs

-----begin code-----
Public Function UpdateAPS(szReport As String) As Integer
Dim oSessionManager As New SessionMgr
Dim Sess As EnterpriseSession
Dim IStore As InfoStore
Dim cReports As InfoObjects
Dim oReportToUpdate As InfoObject
Dim cFileInfo As Files
Dim oFileToUpdate As File
Dim szName As String

Set oSessionManager = CreateObject("CrystalEnterprise.SessionMgr")
Set Sess = oSessionManager.Logon("username", "", "servername", "secEnterprise")
Set IStore = Sess.Service("", "InfoStore")
Set cReports = IStore.Query("SELECT SI_FILES FROM CI_INFOOBJECTS WHERE SI_PROGID = 'CrystalEnterprise.Report' AND SI_NAME = '" & szReport & "'")
Set oReportToUpdate = cReports.Item(1)
Set cFileInfo = oReportToUpdate.Files
Set oFileToUpdate = cFileInfo.Item(1)

szName = oFileToUpdate.Name
MsgBox szName & " will be the file to be updated." & vbCrLf & "There are " & CStr(cFileInfo.Count) & " file(s) associated with this report."

.
.
.

End Function
-----end code-----
 
SDK documentation makes no mention of guarantee of return order. Safest thing to do is examine the collection members. One thing to watch out for is that there was a bug in v8 (don't know if it's been fixed for v8.5) in which the rpt files in the Infostore would sometimes have an erroneous 'tmp' extension.
 
I thought I replied to this posting...anyway, thank you for the reply and I will try the method to examine each member. And I will also keep an out for the .tmp extension.

Thanks again...

rcs
 
The file index will always be 1, but it may not be the first item in the collection. If you want to retrieve the index 1 file, use:
Set oFileToUpdate = cFileInfo.Item("#1")
 
The file index will always be 1, but it may not be the first item in the collection. If you want to retrieve the index 1 file, use:
Set oFileToUpdate = cFileInfo.Item("#1")
 
Hi,

How did you get on with your VB application. I am looking to write something similar. We need to be able to automatically update our pick lists to keep reports inline with our database.

I would be very grateful for any advice on the best way to do this. If you were able to provide the source code for the application this would be great.

Thanks

Phil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top