frazza Posted September 29, 2003 Posted September 29, 2003 Hello, I'm encountering what must be a fairly common issue. I want to set the path of my reports database through code, though I could not find a direct way of doing so. I found a link to this page through this forum, and its' helped somewhat: http://support.crystaldecisions.com/library/kbase/articles/c2010490.asp One problem still remains, however... in my report, I created some queries that are essential to what I need. When I set the database path as the above article mentions, it works except for those cases where I use these queries. In those cases, I get this error that it can't find table "Command"... there is no table Command, that's just the way Crystal Reports calls those saved queries, it seems. public sub ShowReport(report_in as Object) Dim crTables As Tables Dim crTable As Table crTables = report_in.Database.Tables For Each crTable In crTables If crTable.Location <> "Command" Then MsgBox(crTable.Location) crTable.Location = myPath End If Next crvViewer.ReportSource = report_in end sub Quote
Moderators Robby Posted September 29, 2003 Moderators Posted September 29, 2003 Here's the way to query... report_in.RecordSelectionFormula = "{myTable.myColumn} = " & SomeVar Also, You shouldn't have to declare it as OBJECT, you can declare it as ReportDocument.... public sub ShowReport(report_in as ReportDocument) Quote Visit...Bassic Software
frazza Posted September 29, 2003 Author Posted September 29, 2003 Okay, I got it... you need to set the LoginInfo property to something else..... For anyone else encountering a similar problem, here's my code. Dim crTables As Tables Dim crTable As Table Dim sqlUnionQuery As String Dim dbLogonInfo As New CrystalDecisions.shared.TableLogOnInfo dbLogonInfo.ConnectionInfo.ServerName = connectDB.getDBPath crTables = report_in.database.tables For Each crTable In crTables crTable.ApplyLogOnInfo(dbLogonInfo) Next crvViewer.ReportSource = report_in Me.ShowDialog() Quote
frazza Posted September 29, 2003 Author Posted September 29, 2003 I used the RecordSelectionFormula for filtering, but that is not quite the type of query I needed. I actually had a very long Union Query which I needed to use as the report source. Anyway, everything works fine now. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.