W
wvhines
Hello:
I am an ambitious novice...I have a main form "frmGeneralContracting"
that has a subform on it called "frmsubDeliverables" and I am trying
to restrict editing if the current user's login name is in another
subform "frmUserNameRightsProject2Names" that is also attached to the
main form. I want to allow edits, deletes, and additions on the
frmsubDeliverables form to the record and if not they only can view
that record.
I call my GetUserNameRowSecurity function on the OnCurrent event of
the subform frmsubDeliverables.
I have looked at this all day and I can't figure out why my recordset
findfirst isn't working. It seems to totally disregard my code...if I
set the subform properties on the form to false for all 3 allows I
can't edit any records even if my username is in the
tblUserNameRightsProject2Names and if I set the subform properties to
true I can edit all the records regardless if my name is is in
tblUserNameRightsProject2Names for that particular record.
My module code is below. Any help is greatly appreciated. PLEASE
help me.
- Wilma
***********************************
Function GetUserNameRowSecurity()
On Error GoTo RowError_Handler
'************** Code Start **************
Dim myForm As Object
Dim donothing As String
Dim stUser As String
Dim rst As DAO.Recordset
Dim DB As DAO.Database
stUser = Environ("UserName")
Set myForm = Forms!frmGeneralContracting
Set DB = CurrentDb
Set rst = DB.OpenRecordset("SELECT
tblUserNameRightsProject2Names.fldUserNameProjectEdit FROM
GeneralContracting INNER JOIN tblUserNameRightsProject2Names ON
GeneralContracting.ID = tblUserNameRightsProject2Names.ID",
dbOpenSnapshot)
rst.FindFirst ("[tblUserNameRightsProject2Names].
[fldUserNameProjectEdit]" = "'" & stUser & "'")
If rst.NoMatch Then
With myForm
.AllowAdditions = False
.AllowDeletions = False
.AllowEdits = False
End With
Else
With myForm
.AllowAdditions = True
.AllowDeletions = True
.AllowEdits = True
End With
Set myForm = Nothing
End If
'************** Code End **************
Exit_Here:
rst.Close
Set rst = Nothing
Set DB = Nothing
Exit Function
RowError_Handler:
MsgBox Err.Number & ": " & Err.Description
Resume Exit_Here
End Function
I am an ambitious novice...I have a main form "frmGeneralContracting"
that has a subform on it called "frmsubDeliverables" and I am trying
to restrict editing if the current user's login name is in another
subform "frmUserNameRightsProject2Names" that is also attached to the
main form. I want to allow edits, deletes, and additions on the
frmsubDeliverables form to the record and if not they only can view
that record.
I call my GetUserNameRowSecurity function on the OnCurrent event of
the subform frmsubDeliverables.
I have looked at this all day and I can't figure out why my recordset
findfirst isn't working. It seems to totally disregard my code...if I
set the subform properties on the form to false for all 3 allows I
can't edit any records even if my username is in the
tblUserNameRightsProject2Names and if I set the subform properties to
true I can edit all the records regardless if my name is is in
tblUserNameRightsProject2Names for that particular record.
My module code is below. Any help is greatly appreciated. PLEASE
help me.
- Wilma
***********************************
Function GetUserNameRowSecurity()
On Error GoTo RowError_Handler
'************** Code Start **************
Dim myForm As Object
Dim donothing As String
Dim stUser As String
Dim rst As DAO.Recordset
Dim DB As DAO.Database
stUser = Environ("UserName")
Set myForm = Forms!frmGeneralContracting
Set DB = CurrentDb
Set rst = DB.OpenRecordset("SELECT
tblUserNameRightsProject2Names.fldUserNameProjectEdit FROM
GeneralContracting INNER JOIN tblUserNameRightsProject2Names ON
GeneralContracting.ID = tblUserNameRightsProject2Names.ID",
dbOpenSnapshot)
rst.FindFirst ("[tblUserNameRightsProject2Names].
[fldUserNameProjectEdit]" = "'" & stUser & "'")
If rst.NoMatch Then
With myForm
.AllowAdditions = False
.AllowDeletions = False
.AllowEdits = False
End With
Else
With myForm
.AllowAdditions = True
.AllowDeletions = True
.AllowEdits = True
End With
Set myForm = Nothing
End If
'************** Code End **************
Exit_Here:
rst.Close
Set rst = Nothing
Set DB = Nothing
Exit Function
RowError_Handler:
MsgBox Err.Number & ": " & Err.Description
Resume Exit_Here
End Function