Printing a Crystal Report from Access 2007 using VBA

Digital Oatmeal

Registered User.
Local time
Today, 14:46
Joined
May 17, 2011
Messages
15
Hello All,
I generally find answers by searching the forums but this particular one seems very niche.
I have a preexisting Crystal Reports 10 report and I am trying to print it out of an Access 2007 (.accdb) database. I am a complete novice in CR but I do pretty well in Access. The connection in CR to access is ODBC because (first I don’t know what I’m doing and) I am using .accdb instead of .mdb. I have the report printing but every time it does it generates a popup box to select the database. I want that to stop. :confused:
Here’s my code. I would very much appreciate any clear correction anyone can offer my dumb self.;)
Code:
Public Function PrintBOL()
Dim CBO As String
Dim CR As CRAXDDRT.Application
Dim rpt As CRAXDDRT.Report
Set CR = New CRAXDDRT.Application
Set rpt = CR.OpenReport("X:\reportFilePath")
‘ set report to run off of a combo box on the form
CBO = Forms![ProductShipment]![CboOrdno].Value
‘ remove spaces from the Order Number
CBO = Replace(CBO, " ", "")
‘  send CBO to hidden field in the report
rpt.ParameterFields.GetItemByName("DataFeed").AddCurrentValue CBO
rpt.PrintOut promptUser:=False, numberOfCopy:=1
Set rep = Nothing
Set CR = Nothing
End Function
 
First off, CR 10 does not support Access 2007. So, it is lost with an .accdb. I do not know if is possible in your situation to have Access as an older version (2000-2003). I do not have Access 2007, but I do have 2010. I believe there is an option to save the DB as an older version.

I hope this helps.
 
Thanks for the quick reply.

The report works. You can connect with ODBC. I just want the popup asking me select a data source to not come up.

Reverting to a .mdb would probably break so much script it would not be a viable option.
 
Last edited:
Unfortunately I work with Crystal directly and not through any programing. I know that we have some programmers that work with Crystal through .NET, but they have to use a SDK to get it to work.
 
Anyone else gonna take a shot at it? I'm just trying to programmatically verify the connection to CR using VBA.
 
SOLVED----I needed to create a new ODBC data source using the adminitrative tools in control panels. I felt really stupid seeing that I have done that tons of time with every ODBC connection that I have pulled into Access and I just didn't think about the fact that I had to do the same thing to pull Access data into Crystal reports.

All the code works. It needs error handling but it prints the Crystal Report passing the parameter from the combo box.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom