Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Security Coding

Status
Not open for further replies.

dynamictiger

Technical User
Dec 14, 2001
206
AU
I have the following code in my application. The second set of functions dpsOkNew, and NoNew according to microsoft enable me to grant full permissions on the table for the duration of dpsUpdateTable.

However, every time dpsUpdateTable runs I am getting a message that I do not have permission blah blah.


Function dpsUpdateTable()
On Error GoTo Err_ProcedureName

Call dps_OKNew

Set db = CurrentDb
Set rs = db.OpenRecordset("tblDateFlagged", dbOpenDynaset)

If rs.BOF = False Then
rs.MoveFirst

Do While rs.Fields(&quot;MeDate&quot;) <= Date
rs.Edit
rs.Fields(&quot;FlagDate&quot;) = True
rs.Update
rs.MoveNext
Loop

End If


Exit_ProcedureName:
Call dps_NoNew
Exit Function

Err_ProcedureName:
MsgBox Err.Description, vbOKOnly + vbCritical, &quot;Function Update Table&quot;
Resume Exit_ProcedureName
End Function
Private Function dps_OKNew()

Dim db As Database
Dim con As Container

Set db = DBEngine(0)(0)

Set con = db.Containers(&quot;Tables&quot;)

con.UserName = &quot;PoolShop&quot;

con.Permissions = con.Permissions Or DB_SEC_CREATE

End Function
Private Function dps_NoNew()

Dim db As Database
Dim con As Container

Set db = DBEngine(0)(0)

Set con = db.Containers(&quot;Tables&quot;)

con.UserName = &quot;PoolShop&quot;

con.Permissions = con.Permissions And Not DB_SEC_CREATE

End Function
 
What this does is change the permission for the user or group named &quot;PoolShop&quot; so that the user can create new tables (DB_SEC_CREATE added to the Tables container).

You probably want the dbSecFullAccess permission instead. Also, unless the current user is PoolShop or is a member of a group named PoolShop, you should assign con.UserName the value CurrentUser().

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top