Locking records in a continuous form based on criteria

clmarks

Registered User.
Local time
Today, 17:17
Joined
Jan 29, 2007
Messages
69
I have a continuous form. One of the fields is for a voucher number. I need to be able to prevent changes to any record that has something in that voucher number field while allowing edits to records with a blank voucher field. What I have tried so far locks all of the records.

Is what I am trying to do possible? If not, can anyone offer an alternative solution?

Thanks,

Cherry
 
Can you tell us what you have tried so far?
 
It has been several months since I made the attempt, but as I recall, I had a little VB procedure that looked at the voucher field. If that field was empty, all of the fields were editable. If there was something in that field, then all of the fields in the record were locked. The result was that if any of the displayed records had something in the voucher field, then all field were locked on all records.

So, based on your question, can I assume that there should be a way to do this? I'm a very strong user when it comes to the tools built into Access, but I'm pretty weak at writing VB code from scratch.

And thanks for your help. You are fast!

cm
 
You have to remember that when using a continuous form, when you do something to the property of a control, it affect all the controls on the screen. Any validation done based on a control will affect every control for every record depending on the actual record that is selected.

For example, if you have a conditional format for a field that states that if the number is greater than 5, make the background red, then the background for ALL of the displayed results will be red if the the current selected record meets that condition.

Now what you could do, it to list the records in a list box, and have a subform shows all the data that you need. Then link the Parent/Child fields based off of the list box and the subform. This way, as you click on an entry in the list box, you can requery the subform and apply whatever you need to do to lock fields etc.
 
Thanks for the suggestion. I will give it a try.
 
Simple solution:

In the form's Current event, put:

Me.AllowEdits = (Not Len(Me.VoucherNumber & "") > 0)

and replace VoucherNumber with the actual vouchernumber control name (and if the name has spaces use square brackets around it - like Me.[Voucher Number] )
 
@boblarson - Short, sweet and works like a charm!!! If I could give you a star, I would!

Thanx so much!
 

Users who are viewing this thread

Back
Top Bottom