Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a form open from a subform conditionally; read only

Status
Not open for further replies.

maxxev

Technical User
Jul 17, 2008
139
NL
Hi is there a way please to open a form from a subform using acFormReadOnly where that subform is present on 2 seperate forms, and on the other form I want it to open with full user rights....

Basically I have a form "frmIng_Spec_Detail_View"
With Subform "subfrmComponenet_list" (i'll get the spelling mistake later)

On this form the subform is locked but enabled.
It has a button which code is currently this:

Code:
Private Sub Command13_Click()
On Error GoTo Err_Command13_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmComponent_Ings"
    
    stLinkCriteria = "[Ing_Comp_Reg_ID]=" & Me![Ing_Comp_Reg_ID]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command13_Click:
    Exit Sub

Err_Command13_Click:
    MsgBox Err.Description
    Resume Exit_Command13_Click
    
End Sub

Anyone have any thoughts how I can make it read only when the subform "subfrmComponenet_list" is locked locked but open normally otherwise?
Cheers
 
G'day maxxev,

The locked property can be read as well as set so perhaps this would work for you? This example toggles the locked property of a subform when a command button is clicked:

Code:
private sub btnTest_Click()
if forms!MyForm!OneSubform.locked=true then
   forms!MyForm!OneSubform.locked=false
else
   forms!MyForm!OneSubform.locked=true
endif

end sub

Note, if you want to test/set the locked property of a particular control on the sub then you use this syntax instead:

Code:
forms!MyForm!OneSubform.form!MyControl.locked=true

Good luck,

JB

 
Hi, the issue is not locking a subform it is locking a form opened via a button on a subform, but thanks for the reply.

Cheers.
 
I need something like:

Code:
Private Sub Command13_Click()
On Error GoTo Err_Command13_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmComponent_Ings"  
    stLinkCriteria = "[Ing_Comp_Reg_ID]=" & Me![Ing_Comp_Reg_ID]
    
If  subfrmComponenet_list.locked = true then
    DoCmd.OpenForm.locked stDocName, , , stLinkCriteria
    else
    DoCmd.OpenForm stDocName, , , stLinkCriteria

......
 
If subfrmComponenet_list.Locked Then
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly
Else
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If


Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Looks good and thank you for reply, however this comes up with error message:

"Object required"...?

Cheers
 
Use the expression builder to discover how to reference subfrmComponenet_list

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Maxxev,

Why try to do everything in one line of code? You say you'd like something like:

Code:
If  subfrmComponenet_list.locked = true then
    DoCmd.OpenForm.locked stDocName, , , stLinkCriteria
    else
    DoCmd.OpenForm stDocName, , , stLinkCriteria

so why not something like:

Code:
If  subfrmComponenet_list.locked = true then
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    me!subformName.locked=true
else
    DoCmd.OpenForm stDocName, , , stLinkCriteria


JB
 
Thank you, but I still get "object required" as an error.

As a non programmer I don't get why i'm getting it... :(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top