Hi I have this sub called in a module:
Sub getAcessos(aTipoUser As Integer, aObjecto As String)
Dim RSAcessos As DAO.Recordset
Dim Dbs As Database
Dim StrSql As String
Dim tipoAcesso As Integer
Dim tObj As Form
Set tObj = Forms(aObjecto)
'BD a ser utilizada é a actual
Set Dbs = CurrentDb()
StrSql = "select * from acessos where TipoUtilizador=" & aTipoUser & " and objecto='" & aObjecto & "'"
Set RSAcessos = Dbs.OpenRecordset(StrSql, dbOpenSnapshot, dbReadOnly)
If Not RSAcessos.EOF Then
tipoAcesso = RSAcessos("tipoAcesso")
Else
tipoAcesso = 0
End If
Select Case tipoAcesso
Case 1 'Leitura
tObj.AllowEdits = False
tObj.AllowAdditions = False
tObj.AllowDeletions = False
tObj.ShortcutMenu = False
Case 2 'Leitura/Escrita
tObj.AllowEdits = True
tObj.AllowAdditions = True
tObj.AllowDeletions = True
tObj.ShortcutMenu = False
Case 3 'Acesso Negado
MsgBox ("Não tem permissões para aceder a este formulário!, contacte o administrador!")
DoCmd.Close
Case 4 'Acesso Total
tObj.AllowEdits = True
tObj.AllowAdditions = True
tObj.AllowDeletions = True
tObj.ShortcutMenu = True
Case Else 'não tem acesso
MsgBox ("Não tem permissões para aceder a este formulário!, contacte o administrador!")
DoCmd.Close
End Select
RSAcessos.Close
Set Dbs = Nothing
End Sub
when I trie do call the sub in a subform it give a Run.time error '2450', can't find the form... in the line "Set tObj = Forms(aObjecto)" of the sub.
Can someane help.
Thanks.
Sub getAcessos(aTipoUser As Integer, aObjecto As String)
Dim RSAcessos As DAO.Recordset
Dim Dbs As Database
Dim StrSql As String
Dim tipoAcesso As Integer
Dim tObj As Form
Set tObj = Forms(aObjecto)
'BD a ser utilizada é a actual
Set Dbs = CurrentDb()
StrSql = "select * from acessos where TipoUtilizador=" & aTipoUser & " and objecto='" & aObjecto & "'"
Set RSAcessos = Dbs.OpenRecordset(StrSql, dbOpenSnapshot, dbReadOnly)
If Not RSAcessos.EOF Then
tipoAcesso = RSAcessos("tipoAcesso")
Else
tipoAcesso = 0
End If
Select Case tipoAcesso
Case 1 'Leitura
tObj.AllowEdits = False
tObj.AllowAdditions = False
tObj.AllowDeletions = False
tObj.ShortcutMenu = False
Case 2 'Leitura/Escrita
tObj.AllowEdits = True
tObj.AllowAdditions = True
tObj.AllowDeletions = True
tObj.ShortcutMenu = False
Case 3 'Acesso Negado
MsgBox ("Não tem permissões para aceder a este formulário!, contacte o administrador!")
DoCmd.Close
Case 4 'Acesso Total
tObj.AllowEdits = True
tObj.AllowAdditions = True
tObj.AllowDeletions = True
tObj.ShortcutMenu = True
Case Else 'não tem acesso
MsgBox ("Não tem permissões para aceder a este formulário!, contacte o administrador!")
DoCmd.Close
End Select
RSAcessos.Close
Set Dbs = Nothing
End Sub
when I trie do call the sub in a subform it give a Run.time error '2450', can't find the form... in the line "Set tObj = Forms(aObjecto)" of the sub.
Can someane help.
Thanks.