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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lock/ unlock form

Status
Not open for further replies.

ozean

Technical User
Jan 8, 2005
14
SE
I have a mainform and a subform where I store information about monthly bills and salary of two users. Form holds information about date, month and salary. Subform holds information about monthly bills. How can I lock/ unlock the bills of the month when done with a month ? I have tried to add a check box on the main form and use the Me.Allowedit=false when got focus, but then I lock the check box too, unable to unlock it.

Any ideas?

Regards
Stefan/ Sweden

Using Access 2003
 
Can't you have a field "Done" in the table of the subform that when opened from the mainform again disables the subform. The field could contain numeric value, and entered when it meets all criteria and saved. You could then have a passworded button on the mainform which would allow you to enable the subform to edit it again. I might have misunderstood you? Regards
 
If I understand correct...
I 'd try to do it with two functions
Code:
Private Sub chkLock_AfterUpdate()
If Me.chkLock.Value = -1 Then
    Me.AllowEdits = False
Else
    Me.AllowEdits = True
End If
End Sub
'===================
'Allow check/uncheck chkLock
Private Sub chkLock_GotFocus()
    Me.AllowEdits = True
End Sub

Zameer Abdulla
Visit Me (New Look & style)
 
I think I'd try an approach locking all necessary controls, except the checkbox.

[tt]dim ctl as control
for each ctl in me.controls
select case ctl.controltype
case actextbox, accombobox, acsubform
ctl.locked = me("chkToggle").value
end select
next ctl[/tt]

This approach should toggle all text controls, comboboxes and subform control on the main form based on whether the checkbox is checked or not. More looping samples can be found for instance here faq702-5010.

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top