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

Printing Access reports from .Net 6

Status
Not open for further replies.

UHNSTrust

Technical User
Dec 2, 2003
262
GB
Can you print an access report from .Net?

I need to be able to pass the query's SQL statement and then print the report.

Thanks in advance

Jonathan
 
Code:
Dim oAccess As New Access.Application

'The sql below is only the WHERE portion.
'When setting up the reports you will need to have them 'look at all of the data in a table. Ex. select * from foo.
'Then then sql statement below will filter off of the table.
strSQL = "Date_shipped = #" & dateShipped & "# 


With oAccess
        .Visible = True
        .DoCmd.Maximize
        .OpenCurrentDatabase <database path>, False
        .DoCmd.OpenReport <reportname>, acPreview, , strSQL
End With

BTW Don't forget to add your dependencies.

Scott
Programmer Analyst
<{{><
 
Scott,

Thanks for the reply. It works great.

Jonathan
 
I came here looking for something else, but thats a great tip!

Thanks Scott

D
 
Ditto, I hadn't even thought to look for something like this (was going to use Crystal to duplicate a bunch of reports already in Access), saw the topic, figured I would give it a look, and instant time savings, thanks for the tip :)

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Awesome stnkyminky,

You gave total new direction to my application. I am using VB.NET Standard edition, and it does not support crystal reports. I was trying hard to run access reports. But your post gave me the solutions.

Thanks again



 
wow....

I under estimated the need for this code. I should have sold it instead of give it away for free....

j/k

Enjoy!

Scott
Programmer Analyst
<{{><
 
I am new to VB.Net but I cannot get it to recognize the
Dim oAccess As New Access.Application
statement. I tried adding the Microsoft Access 10 object library to the references but get an error. Am I doing something wrong???
 
What is the error you get when trying to add the access library to your project?


**Not recommended but you could declare it like this:
You will not have intellisense if you choose this path.

Dim oAccess as Object
oAccess = createObject(&quot;Access.Application&quot;)



Scott
Programmer Analyst
<{{><
 
When I select it from the com tab, I get the following message:
A reference to &quot;Microsoft Access 10.0 Object Library&quot; could not be added. Converting the type library to .NET assembly failed. A dependent type library 'OWC10' could not be converted to a .NET assembly. A dependent type library 'ADODB' could not be converted to a .NET assembly. Item has already been added. Key in dictionary: ..... Then it lists the ADODB.DLL information.

Any ideas what would be causing this error?
 
Thanks for the Info on the access reports.
I have added this one to my &quot;Save my rear&quot; folder for future use

Terry (cyberbiker)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top