 |
 |

10-14-2003, 12:26 PM
|
|
Regular
|
|
Join Date: Aug 2003
Posts: 57
|
|
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
|
|

10-15-2003, 05:45 PM
|
|
Regular
|
|
Join Date: Oct 2003
Location: Penticton, B.C. Canada
Posts: 83
|
|
|
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.
|
|

10-15-2003, 10:57 PM
|
|
Contributor
|
|
Join Date: Sep 2002
Location: anaheim ca
Posts: 408
|
|
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!
|

10-16-2003, 08:46 AM
|
|
Contributor
|
|
Join Date: Sep 2002
Location: anaheim ca
Posts: 408
|
|
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!
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|