Deleting a user from a Group using VBA

I have an Acc2003 security enabled database containing the names of 
students who log in to book facilities. They are all members of a Group 
called "Students" giving them certain restricted permissions.

Occasionally it is necessary to suspend a student from booking 
facilities, and I would like to achieve this by removing that user 
account from the "Students" Group, but not deleting the user account itself.

Could anyone help me with some VBA code that would achieve this, and 
also later to append that student back to the group by the 
Administrator? (There is a secure form listing user names which the 
administrator can view.)

TIA

Chris
0
Chris
9/16/2007 11:14:23 PM
access 16762 articles. 3 followers. Follow

2 Replies
1703 Views

Similar Articles

[PageSpeed] 23

I found this a while back when I was looking.

Public Sub DeleteUserFromGroup(strUser As String, _ 
strGroup As String)
' Remove a user from a group
' Source: Graham R Seach - MS Access MVP
' 
http://groups.google.ca/group/microsoft.public.access.security/browse_thread/thread/3527785593af7279/b0d043a4d1dd6886
    Dim wrk As DAO.Workspace

    Set wrk = DBEngine(0)
    On Error Resume Next

    wrk.Users(strUser).Groups.Delete strGroup
    wrk.Users.Refresh

    Set wrk = Nothing
End Sub

Public Sub AddUser2Group(strUser As String, _ 
        strGroup As String)
' Add a user to a group
' Source: Graham R Seach - MS Access MVP
' 
http://groups.google.ca/group/microsoft.public.access.security/browse_thread/thread/3527785593af7279/b0d043a4d1dd6886
    Dim wrk As DAO.Workspace
    Dim usr As DAO.User
    Dim grp As DAO.Group

    Set wrk = DBEngine(0)
    On Error Resume Next

    'Create object references
    Set grp = wrk.Groups(strUser)
    Set usr = grp.CreateUser(strUser)

    'Add the group to the user's Groups collection
    grp.Users.Append usr
    grp.Users.Refresh

    Set usr = Nothing
    Set grp = Nothing
    Set wrk = Nothing
End Sub

-- 
Hope this helps,

Daniel P


"Chris Youlden" wrote:

> I have an Acc2003 security enabled database containing the names of 
> students who log in to book facilities. They are all members of a Group 
> called "Students" giving them certain restricted permissions.
> 
> Occasionally it is necessary to suspend a student from booking 
> facilities, and I would like to achieve this by removing that user 
> account from the "Students" Group, but not deleting the user account itself.
> 
> Could anyone help me with some VBA code that would achieve this, and 
> also later to append that student back to the group by the 
> Administrator? (There is a secure form listing user names which the 
> administrator can view.)
> 
> TIA
> 
> Chris
> 
0
Utf
9/17/2007 12:10:06 AM
Daniel wrote:
> I found this a while back when I was looking.
> 

Excellent - many thanks

-- 

Chris
0
Chris
9/17/2007 8:14:29 AM
Reply:

Similar Artilces:

Cannot log in using WindowsID (was able to before)
I just bought MS Money 2007 Deluxe yesterday. The install went smooth, without any issues. I registered a new WindowsID and was able to successfully log into MS Money. However, today when I tried to log into MS Money, the messge apeared that the "Money was not able to recognize your WindowsID" or something like it and that "You will still have access to some functions but will not be able to make online updates". Now I'm not able to make updates. Any idea what this could be? Is the authentication server for WindowsID down or something? See the post under Mon...

How to get user SID?
Hello all: I want to get the user SID,and I use API LookupAccountName,but for two parameters PSID Sid and LPDWORD cbSid I don't know how to set,who could help me?or an example to me?Thanks. Take a look at the code example given here http://msdn.microsoft.com/en-us/library/ms707085(VS.85).aspx Cheers Check Abdoul "Lee Tow" <fbjlt@pub3.fz.fj.cn> wrote in message news:%23QxKbVapKHA.1556@TK2MSFTNGP05.phx.gbl... > Hello all: > I want to get the user SID,and I use API LookupAccountName,but for > two parameters PSID Sid and LPDWORD...

Can't use Merge feature
If I have a postcard file I've already made on the screen, when I try to pull up the "Merge" feature under Tools, it is shaded grey and I can't open it. It insists that I either form a new database list of addresses or edit the one that I want to merge. I don't want to edit the one I want to merge. I just want to MERGE it. If, however, I have just a postcard template on the screen (without it having been made into anything), I CAN pull up the "merge" feature under Tools. It is not shaded out. How do I un-shade the "merge" feature? To merg...

Saving User Settings in Outlook...
Hello everyone, Does anyone know how to save the user settings for MS outlook 2003? Thanks to all who reply, Ismael The reason I would like to be able to save the user settings is so I'll be able to restore these settings should I need to in case I had to do a clean install of WinXP and office 2003 either on the same computer of on another newly bought computer. Thanks to all who reply, Ismael "Ismael" <I_Tena@hotmail.com> wrote in message news:ueqwqfaHGHA.2948@TK2MSFTNGP10.phx.gbl... > Hello everyone, > > Does anyone know how to save the user setting...

the user authentication passed to the platform is not valid 09-20-06
Anyone receive this error message in the CRM Outlook Client? "The user authentication passed to the platform is not valid." Thanks, Scott ...

Restore Exchange 5.5 on 2000 using ArcServe
I've got - Windows NT 4 Server SP6 - Exchange 5.5 SP3 - ArcServeIT 6.61 with Exchange Agent I'm trying to restore the Exchange information (database, mailbox... everything) on another computer. That computer has - Windows 2000 Server SP4 - Exchange 2000 - Brighstore ArcServe 9 (build 2020) with Exchange Agent ------------------- Now the situation: I need to verify that the backup was made correctly (entirely) in order to confirm the total validity of the backup (to validate my disaster recovery plan) and to update to SP4. I tried to find documentation with both Microsoft (for Ex...

Deleting a half sent message
Sorry, forgot to say that I have Outlook 2003:) ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages directly from http://www.ExcelForum.com/ ...

how to query my web site from VBA and return a value to VBA
Hello All, From VBA I would like send a value to my web site, and have it return a value. I've learned how to use FollowHyperlink to send a value to an ASP script, but how can the ASP script send a value back to VBA?? Thanks, Brian Austin, TX You can use xmlhttp to make a request to your web page: '********************************************************* Sub Tester() MsgBox WebResponse("http://www.mydomain.com/myactualpage.asp? info=3Dblah") End Sub Private Function WebResponse(sURL As String) As String Dim XmlHttpRequest As Object Se...

How to use structured reference (ListColumns) in VBA
I want to do something simple...loop through a range retrieving values one at time and taking action on that value. This range is an Excel 2007 table column. Easy enough...BUT I want to use structured references to a table column by NAME, not numbers. I don't want to define new names, just use the table column headings. I've found ways of doing it with quotes, but that's not structured....the names in quotes do not change if the table heading is changed by the user. The formulas change if the table column heading is changed, but I want it to change in VBA to...

Deleted exchange 5.5 site not replicating over the ADC to Exchange 2000 side
We are a part of a shared Exchange 5.5 organization but our site is primarily Exchange 2000/2k3. We maintain a single 5.5 server as the rest of the Org is 5.5. The problem we are seeing is when the folks who control the Organization at the top level remove a site that is no longer used, that deletion is not carrying over the CONFIG_CA agreement to the Exchange 2000/AD side. Our Exchange 5.5 server executes the deletion with no issue. Any ideas on why this deletion is not replicating properly over the ADC and throught the SRS database? In the past we have manually removed the sites/recipie...

Save As using contents of Cell in Name
Can someone help with code that changes the "save As" file name to combination of the original File Name + the contents of a cell, an saves file in same folder as the original. E.G. Original File Name= Timesheet Cells B1= Location Cell C1 = Date in format 3-5-2004 Cell A1 = concatenate(B1,C1) Fle Name will therefore be "Timesheet Location 3-5-2004" The other problem is with the date. When concatenating, how do I forma the date to avoid it looking like "Location 38051" Any help much appreciated Nic -- Message posted from http://www.ExcelForum.com Hi for c...

Error- Project is used by another user -Please select another proj
Please see the subject line, when im trying to open a particular project. it gives me following error. I checked the current users, there are no users. Apart from me. There are some non PA users,i tried to remove them from activity. inspite of me removing them from activity, im geting the same error. Help !!! Ramakrishnan Hello Ram, There is a stranded user in PA000001 table. You need to clear this User/Project combination. Ajay "Ram" wrote: > Please see the subject line, when im trying to open a particular project. > it gives me following error. > > I che...

Protection and grouping
I protected a sheet leaving some columns unprotected. These unprotected columns are grouped. When I protect the sheet, I am no more allowed to hide the grouped columns (by hitting on the "-" button). I allowed all conditions in the "Protect Sheet" window, but nothing changed. Anyone can please help me? Thank you Horst If you already have the outline/subtotals/autofilter applied, you can protect the worksheet in code (auto_open/workbook_open??). Option Explicit Sub auto_open() With Worksheets("sheet1") .Protect Password:="hi", userinterface...

User Authentication Error
Hello All, I am running CRM 3.0. I have the system administrator role. When attempting to merge 2 account records I receive an error that states, "The user authentication passed to the platform is not valid." I cannot merge the records. If anyone can, please advise. thanks. Keith ...

User Defined Required Fields
I have set several field on sub window Sales User-Defined Fields Entry of Sales Transaction Entry as "Required". If the user remembers to click User-Defined, then they become required. But if the user never clicks on User-Defined from Sales Transaction Entry, then they can still save the new document without the required fields entered. Does anyone know what I can do to fix this asside from continual user training? Your answer is VBA. You own Modifer, so you also have VBA enabled. You'll need to write VBA code to open the window (literally, push the button) then set th...

Using Excel in Mac office 2004 with Microsoft/Mac 2008:Analysis toolpack
Although I am disappointed with Office 2008 for Mac because of the absent of Analysis toolpack, I figured things out quite recently that I can still install my Mac office 2004 and use the excel package that contains the Analysis tool pack. How? ...... let me show you: 1. Insert your CD for Mac office 2004 2. When it open on your desk top, two options will be given to you to download the software (a) Office set-up assistant, and (b) Microsoft office 2004. 3. CHOOSE MICROSOFT OFFICE 2004 (Drag the icon onto your desk top) and it will start to run/download. 4. When done, this will appear as ...

How to obtain enumerated attribute declarations from a DTD using MSXML & VB?
I have a VB (VB6, not .NET) application that reads an XML file (using MSXML v3.2 parser); the XML file contains a reference to an external DTD. The DTD has numerous enumerated attribute declarations like so: <!ATTLIST MyElement MyAttribute (One | Two | Three) "One" > The VB code needs to generate dynamic pick-list for all the attributes that appear in the DTD as part of a data-entry application; each dynamically created pick list should contain all the allowable values for the attribute as defined by the DTD (and presented in some kind of multiple choice control like a comb...

Using Excel spreadsheet as input to Access
Hello, I posted this in the New Users forum but only got one answer, so thought I'd try here as well. Like so many others, I am an Excel newbie. I was a mainframe COBO programmer in another life, but that was a few years back My manager would like me to write an app that will take tracking dat from an existing Excel spreadsheet (generated by our system) but onl use a select handful of columns as input to a new Access database tha I will create. I'm guessing that I can either a) create a new edited spreadsheet to b used as input to the Access database or b) use the Import wiza...

Printing Word and excel documents via excel vba
I have a document that has some Excel and some word content i would like to use excel vba to print both a page from word and then a page from excel. I know how to select and open the word document, however i cant find any code to print page X from word. basically i need to: print page 1 of c:\xx\document1.doc print page1 of sheet1 of c:\yy\excelwkbk1.xls print page 2 of c:\xx\document1.doc print page2 of sheet1 of c:\yy\excelwkbk1.xls and so on it will require moving between word and excel - the excel bit i get, but getting back to excel from word, and printing out in word is slightly more...

Using subtotals as single data entries
Sorry about the subject--I couldn't figure out how to describe it simply. I have a large file (16,000 records) of amounts billed by roughly 10,000 service providers. A number of these providers have multiple office locations, so each record is unique to a specific office location. In other words, a provider who billed from 3 different office locations will have 3 entries. Each provider has a unique provider ID number, which stays the same regardless of which office location he is billing from. I want to be able to subtotal the amount billed by each provider for all their office locations...

Using Risk+ with MSP 2007
We use Risk+ as a risk simulation tool. We have discovered that it works approximately 20 times SLOWER in MSP 2007 than MSP 2003. Has anyone else run into this problem. If so, is there a remedy? My hunch this not a generic issue, but surely best that you consult with the Risk+ people on this. --rms www.rmschneider.com On 02/03/10 18:08, Tom Mc wrote: > We use Risk+ as a risk simulation tool. We have discovered that it works > approximately 20 times SLOWER in MSP 2007 than MSP 2003. Has anyone else run > into this problem. If so, is there a remedy? W...

Deleted file in Outlook
I accidentaly deleted a folder in Outlook 2003 and am wondering if it possible to retreive it. Thank you, Karl youthminman@yahoo.com <youthminman@yahoo.com> wrote: > I accidentaly deleted a folder in Outlook 2003 and am wondering if it > possible to retreive it. Unless you permanently deleted it (i.e., held down Shift when pressing Delete), it will be in your Deleted items folder, unless you've emptied that folder. If you have emptied it, other suggestions depend on knowing what data store you're using (PST or Exchange mailbox). -- Brian Tillman ...

Copy Data from One Group of Cells to Another Group
I have five columns of data on two different sheets in the same workbook. One set of columns is sorted in ascending date order the other in descending date order. When I enter data into the last row of Sheet 1, I need the data in that row in columns A, B, C and D to be copied into Sheet 2 columns A, C, D and E in a newly inserted row 14. Is this possible with the use of a macro? I can find the last cell in Sheet 1, but then need to go up one row and back to column A. I am having difficulty with that. Thanks is advance for any assistance offered! /s/ Alan Auerbach On Sat, 26 May 2007, ...

how to use roundup
how to roundup the number to hundreds example 1250101 to 1250200 , 1250901 to 1251000 , 1250750 to 1250800 thank alot =ROUNDUP(A1,-2) -- Kind regards, Niek Otten "r4319hb" <r4319hb@discussions.microsoft.com> wrote in message news:A8D5EA24-858C-49D3-A5ED-481FEBEA36CB@microsoft.com... > how to roundup the number to hundreds example 1250101 to 1250200 , 1250901 > to > 1251000 , 1250750 to 1250800 > thank alot =CEILING(A1,100) -- HTH Bob Phillips (remove nothere from email address if mailing direct) "r4319hb" <r4319hb@discussions.microsoft...

Lock Out Users for Maintenance
Is there a way to temporarily lock out all but the "sa" user? This would be very helpful when tasks such as Check Links is running. Mike, I guess the easiest way is to revoke users access to the company. Regards, -- Mohammad R. Daoud MVP, MCP, MCBMSP, MCTS, MCBMSS Mob: +962 - 79 -999 65 85 Great Package For Business Solutions daoudm@greatpbs.com http://www.greatpbs.com http://mohdaoud.blogspot.com/ "MikeWal" wrote: > Is there a way to temporarily lock out all but the "sa" user? This would be > very helpful when tasks such as Check Links is runni...