473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Need help with user permissions

I have a form that allows users to select criteria for a report. One of
the controls on the form is a multi-select list box. Using the MS
Knowledge Base, I wrote my code to pull the items from the list and
make a querydef for the report. Everything runs great for me but if I
log on as one of my users, I get the "You do not have the necessary
permissions to use the "myquery" object" error. I have given the users
modify permission on this query. The saved query is a RWOP query. I
even tried giving the users administer permissions on the query and it
still will not run. Can anyone tell me what I am doing wrong?

After building the SQL string I run the following:

Set DB = CurrentDb()
Set Q = DB.QueryDefs("myquery")
Q.SQL = strSQL
Q.Close
Set Q = Nothing
Set DB = Nothing

DoCmd.OpenReport "myreport", acViewPreview

Nov 13 '05 #1
5 1310
karinski wrote:
I have a form that allows users to select criteria for a report. One of
the controls on the form is a multi-select list box. Using the MS
Knowledge Base, I wrote my code to pull the items from the list and
make a querydef for the report. Everything runs great for me but if I
log on as one of my users, I get the "You do not have the necessary
permissions to use the "myquery" object" error. I have given the users
modify permission on this query. The saved query is a RWOP query. I
even tried giving the users administer permissions on the query and it
still will not run. Can anyone tell me what I am doing wrong?

After building the SQL string I run the following:

Set DB = CurrentDb()
Set Q = DB.QueryDefs("myquery")
Q.SQL = strSQL
Q.Close
Set Q = Nothing
Set DB = Nothing

DoCmd.OpenReport "myreport", acViewPreview


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Instead of changing the query you could use the Report's Filter property
to get the records you want. Use the report's On Open evetn. E.g.:

' get the selected items from the list box
strListBoxItems = getSelectedListItems(Me!MyListBox)

' filter on the selected items
Me.Filter = "column_name In (" & strListBoxItems & ")"
Me.FilterOn = True

' continue w/ the report
...

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQherPIechKqOuFEgEQKTmQCgqqyuCeBZoiKzXWge8Ma63O +OplcAniWY
j8FpaXQMHokywr+frcSlHCo+
=Z6Sq
-----END PGP SIGNATURE-----
Nov 13 '05 #2
Thanks for getting back so quickly. Your solution would work for me but
the report has a sub report that runs indirectly to the same query. The
report and sub report are NOT linked. The sub report does a "group by"
record count on one of the report's fields. I didn't use the group by
header/footer in the report because I wanted to show all the counts
together at the end of the report. In other words "5/28/05 = 5 items
6/10/05 = 2 items 7/20/05 = 3 items". When I tried to update the
sub report's filter in code I got a cannot change record source after
the report is open error.

Nov 13 '05 #3
Hi
After building the SQL string I run the following:

Set DB = CurrentDb()
Set Q = DB.QueryDefs("myquery")
Q.SQL = strSQL


I don't understand why you're using an existing query and then setting the
query's SQL property. If you're going to do this, you might as well create
a temporary QueryDef.

Set Q = DB.CreateQueryDef("")
Q.SQL = strSQL

Try it - you'll like it!
Nov 13 '05 #4
I now see that I misread your post, and didn't realise you were using this
query as the datasource for a report. That complicates matters.

Have you tried adding WITH OWNERACCESS OPTION to the end of your query?

I must confess I've often had problems with Access's security model and
found things didn't seem to work as they should. Sometimes you find that
creating a new database and copying and pasting the objects into it solves
the problem.

If all else fails you could try:

creating a new querydef (with the appropriate name)
adding it to the querydefs collection
opening the report
deleting the querydef in the report's OnClose event

At what point do you get the error message? When you try to open the report
or sooner?

Nov 13 '05 #5
Hey Captain Nemo,

The last part of your message did the trick!

creating a new querydef (with the appropriate name)
adding it to the querydefs collection
opening the report
deleting the querydef in the report's OnClose event

At first I couldn't understand why the user could delete the query
when they couldn't even modify it before, but I guess because it is
created after they have logged in, they are the "owner" of the query.

Works like a charm now! I wish I had posted sooner. I was afraid I
would get told to "read the help files".

Thanks everyone.

Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Micah Gentry | last post by:
Is there any way to allow a user to use the xp_cmdshell extended stored procedure without giving that user execute permissions to xp_cmdshell in SQL server 6.5? Let me clarify. Lets say I (as the...
2
by: J.Beaulieu | last post by:
Hi I'll have probably to use sql server soon but prior to that I have a question concerning priviledges and security. Is it possible for someone to do like in access, ie creating a db/table...
3
by: teddysnips | last post by:
Currently studying for 70-229. I'm trying to understand how security for users is managed in SQL Server. I've been using SQL Server for a few years now, but without investigating the bits that...
5
by: Kissi Asiedu | last post by:
I have access 97 database being run by multiple users. It was working fine until I created a form and a macro to open the form at start-up. Now only one user can open the table. If a second user...
10
by: Jayme Pechan | last post by:
I wrote a very simply web application and I'm having all sorts of problems with the security getting in the way. All the web application does is load an out-of-process COM server that is running...
0
by: Henrik_the_boss | last post by:
Hello all. I have a couple of aspx pages. When something fails in them, I would like them to be able to log to either a database, a logfile, or the application log. All code is in C# I run...
0
by: hagaiy | last post by:
Has anyone else come across this? We are building an ASP.Net application that uses a certificate and private key in the local machine store. (we are testing it both on windows 2000 & 2003) We...
16
by: peshekeedweller | last post by:
Using asp.net 1.1. vb.net 2003. I am trying to connect to a remote sql server 2000 on a virtual machine running windows 2000 server. I can connect through the server explorer in visual studio,...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
9
by: Brian Hampson | last post by:
I am trying to determine all the groups which the current user has permissions to add a member. Here's my code: foreach (System.DirectoryServices.SearchResult ADSearchres in...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.