Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > Problem opening Access Report from VB


Reply
 
Thread Tools Display Modes
  #1  
Old 10-14-2003, 12:26 PM
raiye raiye is offline
Regular
 
Join Date: Aug 2003
Posts: 57
Unhappy Problem opening Access Report from VB


Hi, someone please help me out. I have an access database and a macro written inside access which shows the access report.
I want to display the access report in VB. I have used the following code to call the Access macro from VB and display the report.
But each time the entire Access is opened and user can easily minimize the report and see the entire database. I want that the User can only view the report and nothing else.
Any help is appreciated in advance.

Public Function OpenReport(mReportName As String, mPreview As String, blnViewOrPrint As Boolean)
Dim accRpt As Object
On Error GoTo MyErr
Set accRpt = CreateObject("Access.Application")
accRpt.Application.OpenCurrentDatabase App.Path & "\capitationmodell_präsentation_access_2000.mdb"
accRpt.DoCmd.RunMacro "Makro_Bericht_Anzeigen", 1
'accRpt.DoCmd.RunMacro "Makro_Bericht_Anzeigen", 1, OpenArgs:="A_Anfügen_Berechnungsnummer|" & 1

accRpt.Application.DoCmd.Maximize
accRpt.Application.Visible = True
If blnViewOrPrint Then
accRpt.Application.DoCmd.Maximize
accRpt.Application.Visible = True
Else
accRpt.Application.DoCmd.PrintOut acPrintAll
End If
Set accRpt = Nothing
Exit Function
MyErr:
If err.Number = 2001 Then
Set accRpt = Nothing
Exit Function
End If
End Function
Reply With Quote
  #2  
Old 10-15-2003, 05:45 PM
cliff_m01 cliff_m01 is offline
Regular
 
Join Date: Oct 2003
Location: Penticton, B.C. Canada
Posts: 83
Default

First option could be to use the access runtime instead of access itself. This solution makes it impossible for them to see the data. Another solution that might work for you is go to the tools menu, and select startup. On the window that pops up uncheck the display database window.
Reply With Quote
  #3  
Old 10-15-2003, 10:57 PM
cmeares cmeares is offline
Contributor
 
Join Date: Sep 2002
Location: anaheim ca
Posts: 408
Default

Quote:
Originally Posted by raiye
Hi, someone please help me out. I have an access database and a macro written inside access which shows the access report.
I want to display the access report in VB. I have used the following code to call the Access macro from VB and display the report.
But each time the entire Access is opened and user can easily minimize the report and see the entire database. I want that the User can only view the report and nothing else.
Any help is appreciated in advance.

Public Function OpenReport(mReportName As String, mPreview As String, blnViewOrPrint As Boolean)
Dim accRpt As Object
On Error GoTo MyErr
Set accRpt = CreateObject("Access.Application")
accRpt.Application.OpenCurrentDatabase App.Path & "\capitationmodell_präsentation_access_2000.mdb"
accRpt.DoCmd.RunMacro "Makro_Bericht_Anzeigen", 1
'accRpt.DoCmd.RunMacro "Makro_Bericht_Anzeigen", 1, OpenArgs:="A_Anfügen_Berechnungsnummer|" & 1

accRpt.Application.DoCmd.Maximize
accRpt.Application.Visible = True
If blnViewOrPrint Then
accRpt.Application.DoCmd.Maximize
accRpt.Application.Visible = True
Else
accRpt.Application.DoCmd.PrintOut acPrintAll
End If
Set accRpt = Nothing
Exit Function
MyErr:
If err.Number = 2001 Then
Set accRpt = Nothing
Exit Function
End If
End Function



I'm not sure of the exact syntax but you can open the database hidden. I think it might be the accRpt.Application.Visible = True
Change that to false. If that doesn't work PM me and I will send you a snippet from my project (it's at work).

It can be done. You can even view the report by saving it to file an loading the snapshot viewer. I have a killer snippet at work.
__________________
Life, it's simply nothing more than a sexually transmitted disease with a 100% mortality rate!
Reply With Quote
  #4  
Old 10-16-2003, 08:46 AM
cmeares cmeares is offline
Contributor
 
Join Date: Sep 2002
Location: anaheim ca
Posts: 408
Default

Quote:
Originally Posted by cmeares
Quote:
Originally Posted by raiye
Hi, someone please help me out. I have an access database and a macro written inside access which shows the access report.
I want to display the access report in VB. I have used the following code to call the Access macro from VB and display the report.
But each time the entire Access is opened and user can easily minimize the report and see the entire database. I want that the User can only view the report and nothing else.
Any help is appreciated in advance.

Public Function OpenReport(mReportName As String, mPreview As String, blnViewOrPrint As Boolean)
Dim accRpt As Object
On Error GoTo MyErr
Set accRpt = CreateObject("Access.Application")
accRpt.Application.OpenCurrentDatabase App.Path & "\capitationmodell_präsentation_access_2000.mdb"
accRpt.DoCmd.RunMacro "Makro_Bericht_Anzeigen", 1
'accRpt.DoCmd.RunMacro "Makro_Bericht_Anzeigen", 1, OpenArgs:="A_Anfügen_Berechnungsnummer|" & 1

accRpt.Application.DoCmd.Maximize
accRpt.Application.Visible = True
If blnViewOrPrint Then
accRpt.Application.DoCmd.Maximize
accRpt.Application.Visible = True
Else
accRpt.Application.DoCmd.PrintOut acPrintAll
End If
Set accRpt = Nothing
Exit Function
MyErr:
If err.Number = 2001 Then
Set accRpt = Nothing
Exit Function
End If
End Function



I'm not sure of the exact syntax but you can open the database hidden. I think it might be the accRpt.Application.Visible = True
Change that to false. If that doesn't work PM me and I will send you a snippet from my project (it's at work).

It can be done. You can even view the report by saving it to file an loading the snapshot viewer. I have a killer snippet at work.



This is the snippet. Hope it works for you. Everything is done "behind the scenes" so you don't ever see access being open.

Code:
Private Sub cmdprintticket_Click() Dim acApp As Access.Application Dim strSQl As String strSQl = "[ID]=" & Me.Text2.Text Set acApp = New Access.Application acApp.OpenCurrentDatabase "Your_DataBase.mdb" acApp.DoCmd.OpenReport "Your_Report", acViewPreview, , strSQl acApp.DoCmd.PrintOut acPrintAll, , , acMedium, 2 acApp.Quit Set acApp = Nothing End Sub

I also do it like this in another form. This creates a snapshot file and displays the report. The first way just pops the report out on the printer.

Code:
Private Sub PrintRedBorderTix() Screen.MousePointer = vbHourglass Dim Snapshotfile As String Snapshotfile = App.Path & "snapshotfile.snp" Snapshotfile = Replace(Snapshotfile, "/", "-") Dim oAccess As Access.Application Set oAccess = New Access.Application oAccess.OpenCurrentDatabase ("PathToDb.MDB") oAccess.DoCmd.OutputTo acOutputReport, "Your_Report", acFormatSNP, Snapshotfile, 0 Form4.snapshotview.SnapshotPath = Snapshotfile oAccess.DoCmd.OpenReport "Your_Report", acViewPreview oAccess.DoCmd.PrintOut acPrintAll, , , acMedium, 2 Form4.Show oAccess.Quit Set oAccess = Nothing Screen.MousePointer = vbNormal End Sub
__________________
Life, it's simply nothing more than a sexually transmitted disease with a 100% mortality rate!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Access report via vb PeterUKVB General 1 07-18-2003 08:26 AM
Access Report From VB Problem keybs Word, PowerPoint, Outlook, and Other Office Products 3 08-20-2002 09:48 PM
Access Report Design nickg96 Database and Reporting 4 08-19-2002 01:12 PM
QB to VB Conversion - By AIO BillSoo Tutors' Corner 0 08-06-2002 11:37 AM
Problem with updating Access Databse from VB app mellis General 0 10-16-2000 03:27 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->