How do I run a Crystal report from Access using passwords (1 Viewer)

Is prehospital care worth the wait for the help you recieve

  • Yes

    Votes: 0 0.0%
  • No

    Votes: 0 0.0%

  • Total voters
    0
  • Poll closed .

Medic1773

New member
Local time
Yesterday, 23:48
Joined
Aug 17, 2011
Messages
2
I am fairly new to the advanced programing in Access. I am using Access 2003 and am trying to connect to a sql database on a server. The sql database is written in Access and the database is password protected. In Crystal I have to use Native Client 10 to connect to the database. Microsoft Server 2005 is the OS on the server.

I have looked all over the internet to find an easy way to connect to the database from vba. I have tried using ConnectInfo, SetLogIn, anything I could find. I do not care if it opens crystal and I enter only the date range or pass the dates and only have to enter the password adnd not the database and user, or it brings it up in Access on the viewer. Presently I am using the Shell statement to open a Crystal report.

To this point I can bring up the viewer but I get an error message saying it can not open the database when it when the code gets to open the viewer. The viewer comes up then the error hits. Using SetLogIn it goes through the each table fine.

I would appreciate any help I can get. Below is the code I am trying now.

'On Error GoTo Err_Register_Click
Dim stAppName As String
Dim Begin As Date
Dim StopDate As Date


Text18.SetFocus
Begin = Text18.Text & " 12:00:00 AM"
Text20.SetFocus
StopDate = Text20.Text & " 12:00:00 AM"

Dim CrxApp As CRAXDRT.Application
Dim CrxRep As CRAXDRT.Report
Dim crxDatabase As CRAXDRT.Database
Dim crxDatabaseTables As CRAXDRT.DatabaseTables
Dim crxDatabaseTable As CRAXDRT.DatabaseTable

Set CrxApp = New CRAXDRT.Application
Set CrxRep = CrxApp.OpenReport("H:\EMS\Reports\Register.rpt")
' CrxRep.DiscardSavedData

'Set Database object to the Report object's Database object
Set crxDatabase = CrxRep.Database
'Set DatabaseTables object to the Database object's Tables object
Set crxDatabaseTables = crxDatabase.Tables


For Each crxDatabaseTable In crxDatabaseTables
crxDatabaseTable.SetLogOnInfo "server", "EMS_Data_v5", "EMS_Admin", "password"
'Debug.Print crxDatabaseTable.Name
Next crxDatabaseTable

CrxRep.ParameterFields.GetItemByName("DateRAnge").AddCurrentRange Begin, StopDate, RangeIncludeLowerBound + RangeIncludeUpperBound

CRViewer91.ReportSource = CrxRep
CRViewer91.ViewReport

Set crxDatabase = Nothing
Set crxDatabaseTable = Nothing
Set crxDatabaseTables = Nothing
Set CrxRep = Nothing
Set CrxApp = Nothing

Thank you in advanced for any help.
 

Users who are viewing this thread

Top Bottom