Access can't find a subform/subsubform

Wappervliegje

Registered User.
Local time
Today, 03:51
Joined
Nov 11, 2014
Messages
23
Dear people,

I get always "Run time error '2450': Microsoft Office Access can't find the form". I don’t know how I can to let know the Access where that subform or subsubform is finding to running the function. See below the three "difference" codes I have made to call the function from the module. Neither of them is working.

Code:
Private Sub Form_Open(Cancel As Integer)
    UserSID (Me.Form.Name)
End Sub

Code:
Private Sub Form_Open(Cancel As Integer)
    UserSID ("Forms![" & Me.Parent.Parent.Name & "]![" & Me.Parent.Name & "].Form![" & Me.Name & "]")
End Sub

Code:
Private Sub Form_Open(Cancel As Integer)
    UserSID ("Forms![frm_D_MRD]![fsub_MRD].Form![fsub_MRD_Materials_New]")
End Sub


See below the function "UserSID" in the module

Code:
Public Function UserSID(frmName As String)
    Dim DLookUpSID As String
        DLookUpSID = DLookup("Security_ID", "tbl_Security_Level", "[Security_ID]=" & _
        Nz(DLookup("User_Security_ID", "tbl_User", "[User_Name]='" & Environ("USERNAME") & "'"), "5") & "")
            Select Case DLookUpSID
                Case 1
                    With Forms(frmName)
                        .AllowEdits = False
                        .AllowDeletions = False
                        .AllowAdditions = False
                    End With
                Case 2
                    With Forms(frmName)
                        .AllowEdits = False
                        .AllowDeletions = False
                        .AllowAdditions = False
                    End With
                Case 3
                    With Forms(frmName)
                        .AllowEdits = False
                        .AllowDeletions = False
                        .AllowAdditions = False
                    End With
                Case 4
                    With Forms(frmName)
                        .AllowEdits = False
                        .AllowDeletions = False
                        .AllowAdditions = False
                    End With
                Case 5
                    With Forms(frmName)
                        .AllowEdits = False
                        .AllowDeletions = False
                        .AllowAdditions = False
                    End With
            End Select
End Function

Please, can you help my to find a wrong? :confused:

With kindly regards,

Wappervliegje! :D

P.S. I hope that my bad English is good enough to understand? :p
 
probably the syntax is more like this.

The sub is a property/method of the form
I am not sure whether the square brackets are required or not, and I think the quotation marks are not required.

Intellisense should work, if its all correct.


Forms![frm_D_MRD]![fsub_MRD].Form![fsub_MRD_Materials_New].usersid
 
me.form.name should be me.name
 
but looking at your function, if you declare it as

Public Function UserSID(frm As Form)

and you code would be

Code:
 Select Case DLookUpSID
                Case 1
                   [COLOR=red] With frm[/COLOR]
                         .AllowEdits = False
                        .AllowDeletions = False
                        .AllowAdditions = False
                    End With
and you would call as

UserSID Me

note no brackets
 
Dear CJ_London and gemma-the-husky,

First I want thank you for your help and effort! :D The solution from CJ_London is the best solution for the problem with my database. This is an informative/helpful moment for me. :D

Greeting from Wappervliegje! :D
 
Another feature the Select Case statement is that you can do this . . .
Code:
Public Sub UserSID(frm As Access.Form)
    Dim DLookUpSID As String
    DLookUpSID = DLookup("Security_ID", "tbl_Security_Level", "[Security_ID]=" & _
        Nz(DLookup("User_Security_ID", "tbl_User", "[User_Name]='" & Environ("USERNAME") & "'"), "5") & "")
    Select Case DLookUpSID
        Case 1, 2, 3, 4, 5
            With frm
                .AllowEdits = False
                .AllowDeletions = False
                .AllowAdditions = False
            End With
    End Select
End Function
. . . and shorten up your code considerably.
 
Are there any other cases then 1, 2, 3, 4 and 5 ?
I suggest you to set what to do in other cases.
 
Dear MarkK and smig,

Thanks for your posts. These cases are an example and they're also not seriously. Now I'm further with specify these cases depently which security level the visitor have. How lower the level, how higher the accessible the visitor have. :D

P.S. MarkK, thanks to let me know that I can add the word "Access" behind the ".Form". :D
 
I am assuming your sub form is embedded in the parent form and not a pop-up window. If so, I always include a control on my underlying table called "LinkID". Then I create a macro so when I click on a certain control on a certain record, it fills the LinkID with the ID control you are using for your records. I then link the child/master to that link.
 

Users who are viewing this thread

Back
Top Bottom