View Full Version : Event-driven record locking... help please


M0E-lnx
09-05-2008, 05:29 AM
I need a way to do some conditional record locking. I'll try to explain.

I'll be using this database that I'm building to order stuff from different vendors.
The vendor will then issue an invoice to me. When this invoice arrives, I'll be checking for price discrepancies and that sort of things and solve them before actually paying the invoice.
Once this invoice has been paid, I need the record that contains this order locked (set to read-only) but I need to be able to add / edit other records

Can anyone suggest a way to do this?

pbaldy
09-05-2008, 05:34 AM
Presuming there's some field in the data that signifies that it's been paid, you can test that field in the current event and set the Allow Edits property accordingly.

M0E-lnx
09-05-2008, 05:38 AM
Presuming there's some field in the data that signifies that it's been paid, you can test that field in the current event and set the Allow Edits property accordingly.

Well, there will be a button to click when the invoice is paid.

Could you elaborate on how to set the allow / edits property for a certain record?

boblarson
09-05-2008, 05:40 AM
I think what Paul means is that you might have a boolean field that you "flip the flag" on when it is paid and then you can test to see if it is true and if so you can set the form's AllowEdits and AllowDeletions to False.

M0E-lnx
09-05-2008, 05:41 AM
But only need that one record locked... there will me many other records to be added and edited

pbaldy
09-05-2008, 05:44 AM
Looks like Bob's here to save me again!

boblarson
09-05-2008, 05:45 AM
But only need that one record locked... there will me many other records to be added and edited

And that is why you would have a field in your table which would have a boolean datatype so that you can check that record as complete. The form's On Current event runs on the change of a record so you would be testing each record to see if it was closed or not and acting appropriately.

boblarson
09-05-2008, 05:45 AM
Looks like Bob's here to save me again!

Sorry, I couldn't resist. I'll try to stop doing that.

M0E-lnx
09-05-2008, 05:48 AM
So... just to make sure I get this right... You lock the form while that one record is being displayed... then when you move on to another record, you run the same check again at lock / unlock the form again.

M0E-lnx
09-05-2008, 07:24 AM
I just tried this and it works... but I guess i need to extend it's functionality a bit

This locks the top (header) of my form
but I also have a subform embedded into it (called "PoItems Subform")
I also need it to lock that form to prevent any edition/deletion there too

How do I accomplish that?

Banana
09-05-2008, 07:43 AM
The simplest way to do this is to add the line in the code where you do the lock/unlock to lock/unlock the subform.

Me.SubformName.Form.AllowEdits=False

M0E-lnx
09-05-2008, 07:53 AM
That worked... Thank you