[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

ADP - DoCmd.OpenReport

Posted on 2004-11-27
8
Medium Priority
?
16,468 Views
Last Modified: 2013-12-05
DoCmd.OpenReport "rptShipping", acViewPreview, , "dbo.orders.or_id = " &
CStr(or_id)

Error:
"The column prefix does not match with a
table name  or alias used in the query"

It really does though, Something with this being a ADP for sure

I was trying this, until I found there was no Open() method:
Dim r As New Access.Report
r.Name = "rptShippingReportSuppliment_Receipts"
r.FilterOn = True
r.ServerFilter = "dbo.orders.or_id = " & CStr(or_id)

Access 2003 - ADP - SQL Server 2000 SP3a
0
Comment
Question by:ginoitalo
  • 3
  • 2
5 Comments
 
LVL 26

Expert Comment

by:Alan Warren
ID: 12689222
 
Hi ginoitalo

try something like this:
   r.ServerFilter = "or_id = '" & CStr(or_id) & "'"

Alan
0
 
LVL 26

Expert Comment

by:Alan Warren
ID: 12689224
or this:

DoCmd.OpenReport "rptShipping", acViewPreview, , "or_id = '" & CStr(or_id) & "'"

Alan

0
 

Author Comment

by:ginoitalo
ID: 12690810
The problem with setting r.ServerFilter is that later, there is no r.Open()

I'll try putting the quotes around the or_id field at work tomorrow
or_id is an int, so I'm going to be mad if that's the solution ;)


0
 

Author Comment

by:ginoitalo
ID: 12699801
Didn't work either:

DoCmd.OpenReport "rptShipping", acViewPreview, , "or_id = '" & CStr(or_id) & "'"


Column prefix dbo.orders does not match with a table in the query

BUT IT DOES !!!!

0
 
LVL 26

Accepted Solution

by:
Alan Warren earned 500 total points
ID: 12702475
Hi ginoitalo

If your report is powered by a stored procedure, setting a wherecondition for the openReport method of the DoCmd object will have no effect, because stored procedures are executed serverside.

You will have success if you power your report on a View or a Table directly.

I have tried setting a global variable prior to using DoCmd.OpenReport, then checking the global var on report open event, and setting the serverfilter to the global variable, but still no joy.



The following method works with stored procedures:
If you modify your stored proc to expect an input parameter you can set the the reports InputParameters property to get its value from the calling form.

Heres an example using NorthwindSQL catalog

The stored procedure: spEmployees
ALTER  Procedure spEmployees @lname Nvarchar(20)=null

AS
  IF (ISNULL(@lname, '') = '')
    SELECT employees.* FROM employees
  BEGIN
  --Create a where condition
    SELECT employees.* FROM employees  WHERE lastname =@lname
  END
GO


The form button code: Form1
Private Sub Command0_Click()
  Me.txtInputParams = "Callahan"
  DoCmd.OpenReport "rptEmployees", acViewPreview
End Sub


Then in the report: rptEmployees

Set the the recordsource property to: spEmployees
Set the InputParameters property to: @lname nvarchar(20) = Forms!Form1.txtInputParams



Alan

0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question