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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal report problem

Status
Not open for further replies.

Imhoteb

Programmer
Oct 11, 2001
131
0
0
BE
Hi all,

I have a problem accessing a Crystal report in VB code. I use VB 6.0
Normally I don't have problems with this but I want to retrieve data from an access database protected with a password.
When I open the report with crystal reports, I must enter the password and then the report opens fine. But when I want to open it through code in VB, the report opens but not showing any data.
How must I include the password in the code so the report shows all the data?

I use Crystal Reports for Visual Basic 4.6.1.0 CRW32 4.6.1.116.


To retrieve data from CR I putted a CrystalReport control on my form. Then I use following syntax to display the report that was premade by Crystal Reports.

***********************Code begins************

Dim sName As String
sName = InputBox("What name do you want to print?")
rptReport.SelectionFormula = "{myTable.Name}='" & sName & "'"
rptReport.PrintReport

********************* end code********************


Is there anyone who can help me with this?
Thx in advance
 

I had a similar problem, but I was connecting from one access database to another password protected access database. Below is the code I used to make the connection at runtime, where xxxxxxx is the password needed. NewPath is a string representing the path to the password protected database - eg "C:\MyTables"

********************************************
Dim dbs As Database
Dim tdf As TableDef
Dim CheckStr As String
Dim NewLink As String

NewLink = ";DATABASE=" & NewPath

For Each tdf In dbs.TableDefs
CheckStr = tdf.Connect
If Nz(CheckStr, &quot;&quot;) <> &quot;&quot; Then
tdf.Connect = NewLink
tdf.Connect = NewLink & &quot;;xxxxxxx&quot;
tdf.RefreshLink
End If
Next tdf

***********************************************

Hope this helps

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top