madeatmidnite
asked on
New record acts like it is locked in continuous form.
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!Med.Locked = Me!SaveCheck
Me!Sig.Locked = Me!SaveCheck
Me![start date] = 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.
I'm stumped. Any help appreciated.
Thanks,
Carrie
If not Me.NewRecord then
Me.Dirty = False
Me!Med.Locked = Me!SaveCheck
Me!Sig.Locked = Me!SaveCheck
Me![start date] = 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.
I'm stumped. Any help appreciated.
Thanks,
Carrie
ASKER
Thanks for sticking with me Arji :)
Still doesn't seem to want to work. Now if any of the Checkboxes are checked, it won't let any of the fields or records change, regardless of whether or not their checkboxes are checked.
Here is my code modified to be a subform:
--------------------------
Private Sub Form_Current()
If Not Forms![AllergyMeds]![MedsC
If Forms![AllergyMeds]![MedsC
Forms![AllergyMeds]![MedsC
Forms![AllergyMeds]![MedsC
Forms![AllergyMeds]![MedsC
Forms![AllergyMeds]![MedsC
End If
End If
End Sub
--------------------------
Any thoughts?
Thanks, Carrie
ASKER
Ok, I have really tried to figure this out. If I take off the
if Me!SaveCheck then
it works ok, even with the last checkbox checked until I go back and try to change one of the saved fields. It doesn't let me change it --which it shouldn't. But after that, the entire field in all the records seems to be locked. It's really strange and I don't understand it. If I (or the users) would never accidently click in one of the saved fields, it would be ok, but I don't think that I can count on that :)
Thanks,
Carrie
if Me!SaveCheck then
it works ok, even with the last checkbox checked until I go back and try to change one of the saved fields. It doesn't let me change it --which it shouldn't. But after that, the entire field in all the records seems to be locked. It's really strange and I don't understand it. If I (or the users) would never accidently click in one of the saved fields, it would be ok, but I don't think that I can count on that :)
Thanks,
Carrie
Hi Carrie,
For clarity's sake I'm going to assume AllergyMeds is the main form and MedsCurrentForm is the subform. AND the code is in the On Current event of the main form AllergyMeds. I'm correcting some typos too....and removing the Bangs---> !
Logicaly the code checks to see if it's a new record,
then it checks the state of a checkbox on the subform,
if the checkbox is checked(True) then it locks the fields on the subform
You will also need to unlock them when SaveCheck is False so an Else condition is appropriate:
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- -
Private Sub Form_Current()
If Not Me.[MedsCurrentForm].Form. NewRecord Then
If Me.[MedsCurrentForm].Form. SaveCheck Then
Me.[MedsCurrentForm].Form. Dirty = False '<-------Not sure what you are trying to do here
Me.[MedsCurrentForm].Form. Med.Locked = True
Me.[MedsCurrentForm].Form. Sig.Locked = True
Me.[MedsCurrentForm].Form. [start date].Locked = True
Else
Me.[MedsCurrentForm].Form. Dirty = True '<-------Not sure what you are trying to do here
Me.[MedsCurrentForm].Form. Med.Locked = False
Me.[MedsCurrentForm].Form. Sig.Locked = False
Me.[MedsCurrentForm].Form. [start date].Locked = False
End If
End If
End Sub
For clarity's sake I'm going to assume AllergyMeds is the main form and MedsCurrentForm is the subform. AND the code is in the On Current event of the main form AllergyMeds. I'm correcting some typos too....and removing the Bangs---> !
Logicaly the code checks to see if it's a new record,
then it checks the state of a checkbox on the subform,
if the checkbox is checked(True) then it locks the fields on the subform
You will also need to unlock them when SaveCheck is False so an Else condition is appropriate:
--------------------------
Private Sub Form_Current()
If Not Me.[MedsCurrentForm].Form.
If Me.[MedsCurrentForm].Form.
Me.[MedsCurrentForm].Form.
Me.[MedsCurrentForm].Form.
Me.[MedsCurrentForm].Form.
Me.[MedsCurrentForm].Form.
Else
Me.[MedsCurrentForm].Form.
Me.[MedsCurrentForm].Form.
Me.[MedsCurrentForm].Form.
Me.[MedsCurrentForm].Form.
End If
End If
End Sub
ASKER
Thanks for writing back. I didn't have it on the on current of the Main form but on the subform. But it still doesn't seem to work. Now it doesn't seem to want to lock anything.
I'm going to try and play with this some more and see if I can get it to work.
thanks,
carrie
I'm going to try and play with this some more and see if I can get it to work.
thanks,
carrie
ASKER
Now when I play with it, if the first record is checked, then all of the records have their fields locked. If the first record is not checked, then all the fields are not locked.
c
c
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If not Me.NewRecord then
if Me!SaveCheck then
Me.Dirty = False
Me!Med.Locked = Me!SaveCheck
Me!Sig.Locked = Me!SaveCheck
Me![start date] = Me!SaveCheck
end if
end if