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

How to Lock Record in Continuous Forms?

Status
Not open for further replies.

bestprogrammer

Programmer
May 7, 2003
2
0
0
US
Hi, I have a unique problem.
I have a form setup as a grid, and the setting as a "continuous form".
what I want to do is lock the record if a flag is set to true. When I lock record, the entire table is locked. even records that have a blank "locked" flag (that is my own flag).
Is it possible to just lock one record, but not the entire form? sometimes the whole column gets locked.
is there an object model for forms? There could be 40 forms on the screen at one time, and I just want to control and disable one of the forms.

thanks for any help

Jim
carrerajim@hotmail.com
 
you have to do it at the control level.
in each of the fields, put in the OnEnter

Code:
Private Sub Ctl200_Enter()
    If Me.WILocked = True Then
        Me.Ctl200.Locked = True
    Else
        Me.Ctl200.Locked = False
    End If
End Sub[code]

you have to do that for each control, and sub in your control name for ctl200 each time. also sub in your check box name for WILocked.

g
 
oh here is something better and easier:

Me.ctl200.Locked = Me.WILocked

since the check box (WILocked) = True or False, we can just set the Locked property of each field to True or False!!
 
Thank you.
unfortunately, that locks all the following rows in the datasheet.
locks the control in all the rows, not just the affected one.

thanks
 
are you putting it in the code for each control? or in the code for the form? it goes in the OnEnter event of the control itself (text box, combo box,etc) not in the form event. it works perfectly for the sample i made myself.
 
GingerR

I'm having the same problem as bestprogrammer and used your suggestion. However, it locks all the following rows for me too. Does it matter that the record I want to lock is on a subform?
 
are your controls bound? what i mean is this:
all the controls in your subform, are their control sources coming from actual fields in a table?
did you put the code in the OnEnter event of every control in the subform that you want locked?
i'll have to check tomorrow at work, but i checked my db that's been in use for more than a year when i first responded to this post.

in every control's OnEnter event, you have to put the code.
i'll check back with you tomorrow.

g
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top