I am trying to allow updates on tables through the form
only.I set the tables permissions to read only and I am tring to programmatically set the record source of the
form with update,delete and addition privilegdes on the table.However when I run the form the I am not able to do anything. I am using the solution below in access 97
Function faq_TblQueryGivePermissions(pstrRecordSource As String, pfrm As Form)
'----------------------------------------------------
' Use OR operator to assign permissions additively
' Pass permission settings to secured workspace routine
' If recordsource is null, set it up (first time only)
' ---------------------------------------------------
Dim lngPermissions As Long
lngPermissions = lngPermissions Or DB_SEC_RETRIEVEDATA
lngPermissions = lngPermissions Or DB_SEC_INSERTDATA
lngPermissions = lngPermissions Or DB_SEC_REPLACEDATA
lngPermissions = lngPermissions Or DB_SEC_DELETEDATA
faq_SetPermissions pstrRecordSource, lngPermissions
If Len(pfrm.RecordSource) = 0 Then 'Access 97
pfrm.RecordSource = pstrRecordSource
End If
End Function
Function faq_TblQueryRemovePermissions(pfrm As Form)
faq_SetPermissions pfrm.RecordSource, DB_SEC_RETRIEVEDATA
End Function
Sub faq_SetPermissions(pstrTblQry As Variant, plngPermissions As Long)
Dim ws As Workspace, db As Database, con As Container, doc, doc2 As Document
Set db = CurrentDb()
Set ws = DBEngine.CreateWorkspace("Temp", "JSJSJ", ""
Set db = ws.OpenDatabase(db.name)
Set con = db.Containers!tables
Set doc = con.Documents(pstrTblQry)
doc.UserName = CurrentUser()
doc.Permissions = plngPermissions
con.Documents.Refresh
db.Close
ws.Close
End Sub
only.I set the tables permissions to read only and I am tring to programmatically set the record source of the
form with update,delete and addition privilegdes on the table.However when I run the form the I am not able to do anything. I am using the solution below in access 97
Function faq_TblQueryGivePermissions(pstrRecordSource As String, pfrm As Form)
'----------------------------------------------------
' Use OR operator to assign permissions additively
' Pass permission settings to secured workspace routine
' If recordsource is null, set it up (first time only)
' ---------------------------------------------------
Dim lngPermissions As Long
lngPermissions = lngPermissions Or DB_SEC_RETRIEVEDATA
lngPermissions = lngPermissions Or DB_SEC_INSERTDATA
lngPermissions = lngPermissions Or DB_SEC_REPLACEDATA
lngPermissions = lngPermissions Or DB_SEC_DELETEDATA
faq_SetPermissions pstrRecordSource, lngPermissions
If Len(pfrm.RecordSource) = 0 Then 'Access 97
pfrm.RecordSource = pstrRecordSource
End If
End Function
Function faq_TblQueryRemovePermissions(pfrm As Form)
faq_SetPermissions pfrm.RecordSource, DB_SEC_RETRIEVEDATA
End Function
Sub faq_SetPermissions(pstrTblQry As Variant, plngPermissions As Long)
Dim ws As Workspace, db As Database, con As Container, doc, doc2 As Document
Set db = CurrentDb()
Set ws = DBEngine.CreateWorkspace("Temp", "JSJSJ", ""
Set db = ws.OpenDatabase(db.name)
Set con = db.Containers!tables
Set doc = con.Documents(pstrTblQry)
doc.UserName = CurrentUser()
doc.Permissions = plngPermissions
con.Documents.Refresh
db.Close
ws.Close
End Sub