Unlocking a subform

ekta

Registered User.
Local time
Today, 18:05
Joined
Sep 6, 2002
Messages
160
Hi:

I use the code below to change the property of the controls on my main form. In this code I want to add the code to unlock my subform. How can I do that.

Main form name: Opportunity
subform name: notes_subform


If objRec.RecordCount = 1 Then
Me!UserName.Visible = False
Me.AllowAdditions = False
Me.AllowDeletions = True
Me.AllowEdits = True
Me!Combo48.Locked = True
Me!Business_Lead.Locked = True

Thanx
Ekta
 
If objRec.RecordCount = 1 Then
Me!UserName.Visible = False
Me.AllowAdditions = False
Me.AllowDeletions = True
Me.AllowEdits = True
Me!Combo48.Locked = True
Me!Business_Lead.Locked = True
Else
Me!UserName.Visible = True
Me.AllowAdditions = True
Me.AllowDeletions = False
Me.AllowEdits = False
Me!Combo48.Locked = False
Me!Business_Lead.Locked = False
End if
 
Kevin:

That's not what I want. How do I reference my subform from my mainform and unlock it.

For example something like this

Me!subformname.enabled = True

Is it the right format???

Ekta
 
I don't think you can lock or unlock a form itself by simply using the 'enabled' method.

You need to use AllowEdits etc

so...

Me!subformname.AllowEdits = True
etc

or try

Forms!MainFormName!subformname.AllowEdits = True
 
Since a subform is just a control on the main form you can lock/unlock it from the main form .
Me.MySubform.Locked=True or False as the case may be
 
I am having this strange problem.

I have secured one of my forms. Users have to enter their userid and password. Once their userid is authenticated it is stored in a table. On my form I have the userid field. I use the code below to see if userid matches with the one in the table. If it does they can edit their records and if it doesn't they cannot. The problem is that if the userid matches it lets the users edit the fields on the mainform but it locks the subform. My form has 3 subforms on it and it is locking all 3 of them. I checked the subform properties and it is not locked. I tried adding this line of code but doesn't work.
Me.Milestone_subform.Enabled = True

Any ideas what might be the reason for this.
Here is my code which checks for userid

Private Sub Form_Current()
'Build SQL String from creating recordset to determine if
'the current record is from the current user
SQL = "SELECT UserName, UserLevel FROM tblBusinessOppurtunity_Main " & _
"INNER JOIN N_tblLocalUser ON tblBusinessOppurtunity_Main.UserName = N_tblLocalUser.UID " & _
"WHERE (Opportunity_ID = " & Me.Opportunity_ID & " AND UserName = '" & LocalUser & "')"

objRec.Open SQL, CurrentProject.Connection, _
adOpenKeyset, adLockOptimistic, adCmdText

'If there is a match, allow the user to add, delete and edit records
If objRec.RecordCount = 1 Then
Me!UserName.Visible = False
Me.AllowAdditions = False
Me.AllowDeletions = True
Me.AllowEdits = True
Me!Combo48.Locked = True
Me!Business_Lead.Locked = True
Me.Milestone_subform.Enabled = True

'Else don't allow the user to add, delete and edit records
Else
Me.AllowAdditions = False
Me.AllowDeletions = False
Me.AllowEdits = False
End If
objRec.Close
End Sub

Thanx
Ekta
 
On the property sheet for the main form, re-name the subform to say Milestonesubform change the reference to to it and try that
 
Etka

You do realise it will be a LOT easier to use the built in Access security to accomplish this.

You can select pernissions like 'Read Only' etc at the click of a button.

Will this 'security system' you useneed to be implemented on other objects in the db?

If so then I think you are doing it the hard way.
 

Users who are viewing this thread

Back
Top Bottom