Passing Display Only Parameters to a MSAccess Report - supressing warning message from Run-Time Vers

  • Thread starter Thread starter Barry G. Sumpter
  • Start date Start date
B

Barry G. Sumpter

Hi all,
I'm using the following article as a base for my application
to print preview reports:


HOW TO: Use Automation to Print Microsoft Access Reports in Access 2000
http://support.microsoft.com/?id=210132


Specifically I'm using the Run-Time Version of Microsoft Access.

To be able to pass parameters to Reports I must retrieve the Record Source
for the report
and change the PARAMATERS clause like:

PARAMETERS rptCriteria TEXT = (No Report Criteria);
Select * from tblCompanys;

to

PARAMETERS rptCriteria TEXT = 'Company: Microsoft';
Select * from tblCompanys;

To do this I MUST open the report in DESIGN mode NOT PREVIEW.

And since I'm using the Run-Time Version of Microsoft Access
I get a message on:
objAccess.DoCmd.OpenReport strRptName, acDesign, strFilter, strWhere

'You do not have exclusive access to the database at this time.
If you proceed to make changes you may not be able to save them'



Does anyone know how to suppress this message?

Preferably with a commandline argument like /silent when I shell to the
Run-Time Version of Microsoft Access.
 
Barry:

The issue is not the run time version or anything else like that for the
error you are receiving. The issue is that with Access 2000 and Xp, to
change any form or report object, the current user must have exclusive
control of the database. So what is likely happening, is that if your main
program which is automating Access has any type of connection established to
the db before you make your design call, its going to throw that error. To
ways to work around this:

1.) Look at your code and make sure that you close any and all connections
to the db (i.e. you can't loop through a recordset that is based on the db
and open a report in design.)

2.) Better yet, rather than setting parameters by opening the report in
design either a.) use the WHERE clause to set your filter, or b.) If you are
trying to pass parameters, see our web site under the Code and Design Tips
in the reports area on one method to modify the reports query to pass
parameters via code, (you could also simply supply a dynamic SQL string
pulled from a module level variable which is set by another sub procedure
your external app calls.)
 
Hi Steve,

Thanks for the verbose response and the time spent on it.

Response to suggestion 1.)

As mentioned in my original posting I'm using the code from the article from
MS.

here are the highlights:

'Open ART (Access Run Time)

x = Shell("C:\Program Files\Microsoft Office\ART\Office\MSACCESS.EXE " &
_
Chr$(34) & strDBName & Chr$(34) & _
"/Runtime /Wrkgrp " & Chr$(34) & _
App.path & "\system.mdw" & Chr$(34))

'set my objAccess to my database

Set objAccess = GetObject(strDBName)

'And open the report (using ART)

objAccess.DoCmd.OpenReport strRptName, acDesign, strFilter, strWhere

Thats it - GetObject and OpenReport no extranious connections or usage
that I can see.

Response to suggestion 2.)
a) The PARAMETERS are NOT part of the query information nor the filter
information
(unless you have a specific example of what you might be
suggesting)

b) The Code and Design Tips for passing parameters is for VBA (Access
Basic) code within MSAccess
and NOT for passing paramaters to a MSAccess Report from MS
Visual Basic.
( I've tried this weeks ago and again just now to make sure I
didn't miss anything.)

also,
'(you could also simply supply a dynamic SQL string pulled from a
module level variable
which is set by another sub procedure your external app calls.)'

Do you have a hyperlink to an example of this so I can see what
you might be suggesting?
Otherwise, I think it might be just the same situation where I
have to a pass a parameter to a
sub procedure to get another procedure to pull my parameters ...
??? How do I tell this procedure
that the parameters are for this (1 of 300) user, who wants this
(1 of 300) report to display this Parameter?

Anyway my solution is working except for the error message described in my
original post.

Does anyone know how to suppress this message?

Thanks,
Barry G. Sumpter
 
Back
Top