Lock the current record only

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi

can any one help me in locking a selected record only" the current record"
and not all records.
 
mhmaid said:
hi

can any one help me in locking a selected record only" the current
record" and not all records.

It's not clear to me what you mean. Under what circumstances do you
want the current record to be locked, and when do you want it to be
unlocked? You can set the form's AllowEdits and AllowDeletions
properties to No in the form's Current event, based on some criteria
about the record that you evaluate in that event, and you could have a
button to "unlock" it, if that's what you want. But you'll have to
explain a bit more about what you are trying to accomplish before I
could give you detailed advice.
 
thank you dirk for help
i am entering expense transactions thru my form "expense reports" i receive
invoices batches(each batch contains many invoices) and have to make record
for each invoice.what i want is when i finish entering invoices for one batch
and checked records for accuracy, to lock those transactions only to prevent
edition or deletion .other transactions should be locked only after checking
them.
 
mhmaid said:
thank you dirk for help
i am entering expense transactions thru my form "expense reports" i
receive invoices batches(each batch contains many invoices) and have
to make record for each invoice.what i want is when i finish entering
invoices for one batch and checked records for accuracy, to lock
those transactions only to prevent edition or deletion .other
transactions should be locked only after checking them.

It seems to me that you would have two tables (primarily) involved here:
an InvoiceBatches table, with one record per batch, and a related table
of BatchInvoices, with one record per invoice, each record stamped with
the BatchID (or equivalent key) of the batch it belongs to. The tables
would be in a one-to-many relationship. Of course, you could call these
tables by other names that make sense to you.

Then you would enter and edit these data via a main form/subform
arrangement. The main form would be based on the InvoiceBatches table,
and the subform would be based on the BatchInvoices table nd linked to
the main form by the BatchID field.

The InvoiceBatches table would have a field defined to indicate that
data entry for this batch has been completed and verified. This field
might be a simple Yes/No field represented on the form by a check box,
or it might be a date/time field that your code would manipulate such
that, if the field isn't Null, it contains the date and time on which
the batch was completed and validated. Either way, this field can be
tested in code to see if this batch is complete and should be locked.

You would then have code in the main form's Current event that does
something like the following:

'----- start of example code -----
Private Sub Form_Current()

Dim blnEditable As Boolean

If Me!chkBatchComplete Then
blnEditable = False
Else
blnEditable = True
End If

Me.AllowEdits = blnEditable
Me.AllowDeletions = blnEditable

End Sub
'----- end of example code -----

Note two things about the above code:

1. It locks both the main form and the subform.

2. All controls on these forms become uneditable -- even unbound
controls. If you need a mechanism to unlock the form after you've
locked it, you can put a command button on the form to do it.

Whatever mechanism you use to mark a batch as being complete and
verified, you'll want that mechanism to include code that either calls
the Form_Current event procedure after marking the record, or else locks
the form directly.
 
thank you very much for your detailed reply.I tried that and found it
exactly what i am looking for.
thank again for help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top