Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 15th, 2005, 10:09 AM
Authorized User
 
Join Date: Apr 2005
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default user rights and access

I have an Access front end connecting to a SQL backend. I have a particular field that I only want to allow one or maybe two particular users to be able to change from the front end. I have user accounts set up in a workgroup file. but how do I go about applying user accounts to a particular control. in this case a drop down menu selector.

Many thanks

Robert Dolphin

 
Old June 18th, 2005, 10:23 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

This is going to be a manual process that you can control on forms. You won't be able to prevent the user from accessing a particular field if they have access to the table directly or through a query.

To prevent access to a control on a form, when the form loads, set the Enabled property to false if "CurrentUser" isn't allowed access. I believe CurrentUser will be set when the user logs on through the Workgroup file.

I'm not sure what you mean by a "drop down menu selector". If this is a "combo box", the above should work. If this is a toolbar menu item, you can disable the control like above, but you'll have to do it during your application startup.

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org
 
Old June 18th, 2005, 02:11 PM
Authorized User
 
Join Date: Apr 2005
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks rjweers. SOrry I did mean Combo Box. How do I go about "programming" it? I'm not very good with access and VB. I'm still very much learning. I was thrown in at the deep end by my employer!!

Many Thanks
 
Old June 18th, 2005, 05:51 PM
Authorized User
 
Join Date: Apr 2005
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

One other thing, can I refresh the status of an object (i.e. enable/disabled) with reloading the entire form?
 
Old June 19th, 2005, 09:19 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

Sink or swim, eh? :)

I'm not really sure how much of this I should describe. You really need to start looking into some books about object oriented programming, particularly in relation to Access.

A quick overview...

In object oriented programming the terms are pretty self-descriptive. For example, an Object is a thing that is more-or-less "tangible". A form is an object. A combo box on a form is an object. Each object has Properties. Properties are the characteristics of an Object. The size of the form, height and width, are Properties of the form. The location of the combo box on the form, top and left, are Properties of the combo box. A combo box has the Property "Enabled". Events occur in relation to objects. For example, when a user opens a form, several Events occur for that form. Load and Activate are two of those events.

For the purposes of your code, you're interested in the Load event. So you'll look at the Properties of the form and give the "On Load" Event Property some code. That is a bit confusing. The code is actually a Property of the form. But the code is something that will execute as a result of an Event that occurs in relation to the form.

If you're with me so far...

When you select the dropdown for the "On Load" event property of the form, you'll see "[Event Procedure]". Select that then click the elipse (...) next to it to open the Visual Basic Editor (VBE). You'll see that Access creates the Form_Load event template where you can write your code. Your code will be something like:
Code:
If (CurrentUser = "username1") or (CurrentUser = "username2") then
    Me.ComboBoxName.Enabled = True
Else
    Me.ComboBoxName.Enabled = False
End If
I'm not clear about what you want to do to "refresh the status with reloading the form". The On Load (Form_Load) event is kicked off every time the form is loaded (i.e. every time a user opens a form in Form mode -- not design mode). So the Form_Load code will run to enable or disable the ComboBox control whenever the form is loaded.

From there you're just going to have to get into this on your own. I really don't know how "basic" I need to be to get you started. And it is difficult to describe all of this without knowing whether you're making the connections. You might try looking at the Northwind sample database for some ideas.

Just have some confidence that you can do this. It really isn't terribly difficult. There's a lot to learn. I seem to learn something new every week and I wrote 4 chapters in "Access 2003 VBA Programmer's Reference". But you don't have to know all of it to do the things you need to do to get started. In fact, I'm amazed that you're tackling the Workgroup File. That was one of the chapters I wrote and Access Security is pretty confusing!
 
Old June 19th, 2005, 10:46 AM
Authorized User
 
Join Date: Apr 2005
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sink or swim pretty much sums it up to be honest!!

i can't thank you enough for your help. and yeah it did all make sense :) Some parts of this Access lark I find easy to grasp and others take a bit longer! but hey ho, no one ever learnt anything by shying away from a challenge!! I've spent a lot of time admining (bad grammar I know, but it'll do! :)) and running windows servers so I understand the principles behind security etc. it's just a case of trying to wrap my head around how to really use it from a programming point of view, which is all new to me! But once again thanks ever so much for your help. I appreciate you taking the time to write such a long reply!!!

Cheers

Rob





Similar Threads
Thread Thread Starter Forum Replies Last Post
<bean:message key="error.access.rights"/> sparun1607 Struts 1 September 23rd, 2011 03:08 AM
new folder and access rights margeb C# 1 November 14th, 2005 04:24 AM
creating new user with admin rights... dungey MySQL 1 April 20th, 2004 06:08 PM
How to create a text file with particular rights? oranee VB How-To 2 July 31st, 2003 09:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.