Make sure you always the full path and file name for the cTable parameter.
>Criag,
>
>We've discussed this a few times, but Im not sure if I have
>ever completely solved it.
>
>When creating a report, I create a snapshot of the data into a Fox2x
>table called 'Temp1'.
>
>I create a report based off an xBase data source and add into the
>report the table 'Temp1'
>
>But in runtime in my app, I might generate the data into a completely
>different table, who's name is generic, sat "_KD2LD2L.dbf". I often use
>the SYS(2015) function to create a unique table name for this.
>
>Next I need to tell the report that the table 'Temp' is really '_KD2LD2L.dbf'.
>So I created this short procedure:
>
>
>PROCEDURE SetTableLocation(oReport as Object, cTable as String, cAlias as String)
>
> LOCAL oDatabase, oTables, lFound
>
> WITH This
>
> cTable = UPPER(ALLTRIM(cTable))
> cAlias = UPPER(ALLTRIM(cAlias))
>
> IF EMPTY(JUSTSTEM(cTable))
> cTable = ALLTRIM(cTable) + ".dbf"
> ENDIF
>
>
> oDataBase = oReport.Database
> oTables = oDataBase.Tables
>
> FOR iTable = 1 TO oTables.Count
>
> oTable = oTables.Item(iTable)
>
> IF cAlias = UPPER(ALLTRIM(oTable.Location))
>
> lFound = TRUE
> oTable.SetTableLocation(cTable, JUSTSTEM(cTable), "")
>
> EXIT
>
> ENDIF
>
>ENDFOR
>
>
>This basically searches through the table collection looking for the alias
>'Temp1' and sets the full path and name of that table to my new table.
>
>Sometimes this works, but fiarly often I get a 'Logon Failed' error. I'm at
>a loss, and when I called Crystal and and asked them about it, the tech acted
>as if he had never heard of VFP, lets alone test in it.
>
>So, I'm really stuck on this. Could use your help.
>
>Many Thanks
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer