تفضل اخي الكريم
جرب التعديل ووافنا بالنتيجة
Function FunModulePermissions()
On Error GoTo Macro1_Err
With CodeContextObject
If DCount("ID", "Tbusers", "deCode([UName],'User')='" & Trim(User) & "'") = 0 Then
MsgBox " لا تملك الصلاحيات للدخول ", vbCritical + vbMsgBoxRight, "تنبيه"
DoCmd.CancelEvent
If CurrentProject.AllForms("FrmMain").IsLoaded = False Then
.AllowAdditions = False
.AllowEdits = False
.AllowDeletions = False
Else
If (Forms!Frmmain!UAddData = False) Then
.AllowAdditions = False
End If
If (Forms!Frmmain!UEditData = False) Then
.AllowEdits = False
End If
If (Forms!Frmmain!UDeleteData = False) Then
.AllowDeletions = False
End If
End If
End If
Macro1_Exit:
Exit Function
Macro1_Err:
MsgBox Error$
Resume Macro1_Exit
End With
End Function