Coding Security (1 Viewer)

dynamictiger

Registered User.
Local time
Today, 07:46
Joined
Feb 3, 2002
Messages
270
According to Microsoft the functions dps_OkNew should allow my code to update the underlying table even though the user has no direct permissions on this table.

However, everytime I tun this code it prompts me with a warning that I do not have update permissions blah blah.


Code:
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("MeDate") <= Date
rs.Edit
rs.Fields("FlagDate") = True
rs.Update
rs.MoveNext
Loop

End If


Exit_ProcedureName:
    Call dps_NoNew
   Exit Function

Err_ProcedureName:
   MsgBox Err.Description, vbOKOnly + vbCritical, "Function Update Table"
   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("Tables")
       
       con.UserName = "PoolShop"
       
       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("Tables")
       
       con.UserName = "PoolShop"
       
       con.Permissions = con.Permissions And Not DB_SEC_CREATE
       
   End Function
 

bjackson

Registered User.
Local time
Today, 16:46
Joined
Jan 3, 2003
Messages
404
Would running a query with owners permission solve your problem?
 

dynamictiger

Registered User.
Local time
Today, 07:46
Joined
Feb 3, 2002
Messages
270
Apparently not, which is why I am looking at this code.
 

Users who are viewing this thread

Top Bottom