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

trouble opening new record if record above it is locked. 1

Status
Not open for further replies.

naoaja

Technical User
Aug 27, 2004
48
US
I use the following code to lock the record if the checkbox is checked. (In continuous form)

If not Me.NewRecord then
Me.Dirty = False
Me!Parts.Locked = Me!SaveCheck
Me!Employee.Locked = Me!SaveCheck
Me![start date].locked = Me!SaveCheck
end if

This works great except ONLY if there is a the SaveCheck box is checked on the LAST entered record. If that is the case, then it will not allow me to enter a new record. If that checkbox (the Last one only) is not checked, I can enter in information into a new record. If it is checked, then the new record acts as if it is locked.


Actually I just messed with it some more and now it seems like if I click on any of the current records where the fields are locked, then the whole field becomes locked. Sometimes, if I double click the checkbox, it will let me start entering data again.

This just doesn't make sense to me. I would appreciate any help.
Thanks,
naoaja
 
How are ya naoaja . . . . .

Thats [blue]normal behavior[/blue] for an [blue]unbound control[/blue] in the [blue]Detail Section[/blue] of a continuous form.

[purple]Add a Yes/No field to the appropriate table . . .[/purple]

Calvin.gif
See Ya! . . . . . .
 
Hi TheAceMan1,

Thanks for the reply.

I do have a yes/no field SaveCheck on the table. The form is based on a query of the table -- does that make a difference? When I check one of the boxes, it will show up in the table under the correct record.

Does this help at all?

Thanks,
naoaja
 
OK naoaja . . . . .

Your post origination is misleading (not your fault).
naoaja said:
[blue] . . . if there is a the SaveCheck box is checked on the LAST entered record. If that is the case, then [purple]it will not allow me to enter a new record[/purple].[/blue]
Be more specific about this! Its as if your saying a new record already has a check in the checkbox!



Calvin.gif
See Ya! . . . . . .
 
Be more specific about this! Its as if your saying a new record already has a check in the checkbox!

That's the way I thought it was acting also.

But when I really looked at the form, if I just keep entering data correctly and don't backtrack and try to get into one of the fields that is already locked, it works like a dream. But if I click in a locked field, it won't let me change anything (which is shouldn't) but then it seems like that field is locked in all the records regardless of whether the checkbox was checked or not. If I then click on a field of one that the check box is not checked, it then lets me continue to add correctly.

If it was just me that was going to use it, I wouldn't worry about it, but I can see users accidently clicking on a locked field, or trying to change it, forgetting that it is locked.

naoaja
 
naoaja said:
[blue]but then it seems like that field is locked in [blue]all the records regardless[/blue] of whether the checkbox was checked or not.[/blue]
[purple]Control properties can't discriminate records![/purple] . . . . so yes, [purple]if one field is locked there all locked, including a new record.[/purple]

What you need is [purple]Conditional Formatting[/purple], its just that it doesn't afford control of the [blue]Lock[/blue] property. You control the [blue]Enable[/blue] property though, which is just as good and has the added advantage of giving that [blue]disabled look[/blue] (easy to know who's locked).

Calvin.gif
See Ya! . . . . . .
 
You can't do conditional formatting on a check box though can you? Or I guess you probably mean to do conditional formatting on each field relative to the checkbox? Haven't played much with conditonal formatting, will have to give it a try.

thanks,
naoaja
 
naoaja said:
[blue]You can't do conditional formatting on a check box though can you?[/blue]
Correct!
naoaja said:
[blue]I guess you probably mean to do conditional formatting on each field relative to the checkbox?[/blue]
Correct!

BTW, I should've been more explicit when I said:
TheAceMan said:
[blue] . . . so yes, if one field is locked there all locked, including a new record.

Should Be:

. . . so yes, if a field is locked its locked in all records, including a new record.[/blue]

If ya have problems setting it up do this:
[ol][li]In form design view [blue]select the control of interest[/blue].[/li]
[li]Click [blue]Format[/blue] - [blue]Conditional Formatting[/blue].[/li]
[li]Format should be: [purple]Expression Is[/purple] [SaveCheck]=True[/li]
[li]Click the enable Control
CondFmtEn.BMP
[/li]
[li]Close the conditional format window.[/li]
[li]Repeat the above for other controls of interest.[/li][/ol]
Be aware: [blue]you don't have to have the checkbox on the form.[/blue] You can still access any field as long as its in the forms [blue]Field List[/blue]. You can [blue]detect a key combination[/blue] ([purple]Ctrl + Alt + L[/purple] in the example) to toggle the checkbox of the Current Record (excluding new record). Following is an example using the forms [purple]KeyDown[/purple] event:
[ol][li]In design view, set the forms [blue]Key Preview[/blue] property to [purple]Yes[/purple].[/li]
[li]In the [blue]KeyDown[/blue] event of the form, copy/paste the following:
Code:
[blue]   If Not Me.NewRecord Then
      If Shift + KeyCode = 82 Then
         Me!SaveCheck = Not Me!SaveCheck
      End If
   End If[/blue]
[/li][/ol]
[purple]When your satisfied remove the checkbox . . .[/purple]

Calvin.gif
See Ya! . . . . . .
 
thanks !

looks like fun....

naoaja
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top