M
Marlie
Hello, this is my first post here. I hope to have a long relationship with
everyone here. My forum's website changed so dramatically, I can't even find
my posts, so I am giving this one a go.
I am struggling a bit with a module that I am writing.
I am setting up a permission module. There is a table that list a form and a
control on that form.
When a form is opened, the module runs first to find out on that specific
form, what can be seen and what not.
My code worked fine with the Docmd.SetProperty formula, but I cant get it to
work on subforms, so I tried something else.
The following module works on the principle eg. me.control.visible.true But
noting happens. Seems like I need to action it somehow. I think my string
comes out as
"Forms!frmDocumentNumberEntry!DocTitle.Visible = False"
insted of
Forms!frmDocumentNumberEntry!DocTitle.Visible = False
Public Function SetPermToForm()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Dim frmname As String
Dim frm As Form
Set frm = Screen.ActiveForm
frmname = "like '" & frm.Name & "'"
MsgBox frmname
Dim strSQL As String
strSQL = "SELECT tblEmployeePermission.Emp_ID,
tblEmployeePermission.PermYes, tblEmployeePermission.PermForm,
tblEmployeePermission.PermItem, tblEmployeePermission.PermFunct " & _
"FROM tblEmployeePermission " & _
"WHERE (((tblEmployeePermission.PermForm) " & frmname & "))"
Set rs = db.OpenRecordset(strSQL)
rs.MoveFirst 'move to the first record in the recordset
Do Until rs.EOF
Dim strprop As String
'The following command does not happen. In the Debug print window it shows
as if you would have typed in Forms!frmDocumentNumberEntry!DocTitle.Visible =
False
strprop = "Forms!" & rs!permform & "!" & rs!permitem & "." & rs!permfunct &
" = "
strprop = strprop & rs!permyes
'Answer to STRPORP IS:
'Forms!frmDocumentNumberEntry!DocTitle.Visible = Fals
'Forms!frmDocumentNumberEntry!ChildfrmDocumentNumberEntryRev.Form!DocStatus_ID.Vi
sible = False
rs.MoveNext 'move to the next record in the recordset
Loop 'loop back to 'Do Until rs.EOF'
rs.Close 'cleanup
db.Close
Set rs = Nothing
Set db = Nothing
End Function
everyone here. My forum's website changed so dramatically, I can't even find
my posts, so I am giving this one a go.
I am struggling a bit with a module that I am writing.
I am setting up a permission module. There is a table that list a form and a
control on that form.
When a form is opened, the module runs first to find out on that specific
form, what can be seen and what not.
My code worked fine with the Docmd.SetProperty formula, but I cant get it to
work on subforms, so I tried something else.
The following module works on the principle eg. me.control.visible.true But
noting happens. Seems like I need to action it somehow. I think my string
comes out as
"Forms!frmDocumentNumberEntry!DocTitle.Visible = False"
insted of
Forms!frmDocumentNumberEntry!DocTitle.Visible = False
Public Function SetPermToForm()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Dim frmname As String
Dim frm As Form
Set frm = Screen.ActiveForm
frmname = "like '" & frm.Name & "'"
MsgBox frmname
Dim strSQL As String
strSQL = "SELECT tblEmployeePermission.Emp_ID,
tblEmployeePermission.PermYes, tblEmployeePermission.PermForm,
tblEmployeePermission.PermItem, tblEmployeePermission.PermFunct " & _
"FROM tblEmployeePermission " & _
"WHERE (((tblEmployeePermission.PermForm) " & frmname & "))"
Set rs = db.OpenRecordset(strSQL)
rs.MoveFirst 'move to the first record in the recordset
Do Until rs.EOF
Dim strprop As String
'The following command does not happen. In the Debug print window it shows
as if you would have typed in Forms!frmDocumentNumberEntry!DocTitle.Visible =
False
strprop = "Forms!" & rs!permform & "!" & rs!permitem & "." & rs!permfunct &
" = "
strprop = strprop & rs!permyes
'Answer to STRPORP IS:
'Forms!frmDocumentNumberEntry!DocTitle.Visible = Fals
'Forms!frmDocumentNumberEntry!ChildfrmDocumentNumberEntryRev.Form!DocStatus_ID.Vi
sible = False
rs.MoveNext 'move to the next record in the recordset
Loop 'loop back to 'Do Until rs.EOF'
rs.Close 'cleanup
db.Close
Set rs = Nothing
Set db = Nothing
End Function