PC Review


Reply
Thread Tools Rate Thread

NEED HELP!!!! Error when opening a Access report

 
 
=?Utf-8?B?VmluY2VsMmsy?=
Guest
Posts: n/a
 
      22nd Mar 2005
Everything works fine untill I try to use a where clause, then I get this
error: There was a problem accessing a property or method of the OLE object.

System.Runtime.InteropServices.COMException: There was a problem accessing a
property or method of the OLE object.

Here's my code, I can't find anything wrong.
Public Function fGetSnapshot(ByVal sReportName As String)
Dim acApp As Access.Application
Dim myReport As Access.Report
Dim strDBPath As String
Dim StrFileName As String
Dim StrFilePath As String
Dim strSQL As String
Dim strFilter As String
Const acFormatSNP = "Snapshot Format (*.snp)"
Dim sUserName As String
Dim fso
fso = CreateObject("Scripting.FileSystemObject")
strDBPath = Server.MapPath("..\YMSReports\DB\UltraReporting_SQL.adp")
StrFilePath = Server.MapPath("..\YMSReports\DB\")

sUserName = Session("username")

acApp = New Access.Application
With acApp
.OpenCurrentDatabase(strDBPath)


strFilter = ""

' Print the report.
strSQL = "[tblYardOnly].[YARD_PO_UserField2] = " &
cboDiv.SelectedValue
With acApp.DoCmd
If Len(strSQL) > 0 Then
.OpenReport(sReportName, Access.AcView.acViewPreview, ,
strSQL)
Else
.OpenReport(sReportName, Access.AcView.acViewPreview)
End If

End With

'.DoCmd.OpenReport(sReportName, Access.AcView.acViewPreview, ,
strSQL)
StrFileName = Mid(sUserName, 1, InStr(1, sUserName, "@",
CompareMethod.Text) - 1) & sReportName & ".snp"
'if it is already there, delete it
.DoCmd.OutputTo(Access.AcOutputObjectType.acOutputReport, ,
acFormatSNP, StrFilePath & StrFileName)
End With


acApp.Quit()
acApp = Nothing

Response.Redirect(StrFilePath & StrFileName, False)

End Function

Thanks
 
Reply With Quote
 
 
 
 
Paul Clement
Guest
Posts: n/a
 
      22nd Mar 2005
On Tue, 22 Mar 2005 06:21:01 -0800, Vincel2k2 <(E-Mail Removed)> wrote:

¤ Everything works fine untill I try to use a where clause, then I get this
¤ error: There was a problem accessing a property or method of the OLE object.
¤
¤ System.Runtime.InteropServices.COMException: There was a problem accessing a
¤ property or method of the OLE object.
¤

On which line of code is the error occurring?


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening report hangs Access 2007 but not Access 2003 =?Utf-8?B?TmljayBNZXllcg==?= Microsoft Access 18 5th Nov 2007 10:24 AM
Installation of Access 2003 prevents Access 2000 from opening a report aemarchant Microsoft Access Reports 0 26th Apr 2007 11:59 AM
Installation of Access 2003 prevents Access 2000 from opening a report 41454D@googlemail.com Microsoft Access Reports 0 26th Apr 2007 09:51 AM
Can I export Access report as HTML in VB without opening Access =?Utf-8?B?c2Nyb3NrZXk=?= Microsoft Access Reports 1 20th Oct 2004 01:29 PM
Can I Export access report as html from VB w/out opening access =?Utf-8?B?c2Nyb3NrZXk=?= Microsoft Access Reports 0 20th Oct 2004 01:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:55 AM.