Link to home
Start Free TrialLog in
Avatar of ruby_yeheskel
ruby_yeheskel

asked on

Microsoft Access Reports Automation

I'm Using Visual Basic To Open An Access Report Like This:

Private Sub CmdOpenReport_Click()
  RunReport "report1", "Customers.CustomerID='11111111'"
End Sub

Public Sub RunReport(strReport As String, Optional WhereCondition As String)
   Dim mobjAccess As Object
   Set mobjAccess = New Access.Application
   mobjAccess.DoCmd.Hourglass True
   ' Open the database
   mobjAccess.OpenCurrentDatabase CurrentDbPath
   ' Open the report in preview mode
   mobjAccess.DoCmd.OpenReport strReport, acViewPreview, , WhereCondition
   ' Maximize the report window
   mobjAccess.DoCmd.Maximize
   ' Show the Access window
   mobjAccess.Visible = True
   mobjAccess.DoCmd.Hourglass False
End Sub

My Problem Is That I Want To Leave Access Application Open After Leaving The "RunReport" Sub And Let The User Print His Report Wherever He Like.
That's Why I'm Not Closing My "mobjAccess" Object At The End Of My Sub.

So Why When I'm Leaving The Sub The Access Application
Is Closing ?

How Can I Leave The Access Application(My Specific Report) Open ?????????????????


ASKER CERTIFIED SOLUTION
Avatar of kfrick
kfrick

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Richie_Simonetti
Only a think:
Dim mobjAccess As Object   ' hummm....
Dim mobjAccess As Access.application     ' :)
 
Avatar of ruby_yeheskel
ruby_yeheskel

ASKER

kfrick,

Thanks

You Know Sometimes The Head Is Not Working.