PC Review


Reply
Thread Tools Rate Thread

Lock and Unlock Select Records

 
 
CJ
Guest
Posts: n/a
 
      15th Nov 2005
Hi (A2K3)

Is it possible to be able to lock a select group of records via a button and
also be able to unlock them with a button?

After a time period is closed off by the finance department, we want to be
sure that those records are not edited in the database. It would be ideal if
we were able to push a command button, enter an end date and then have all
of the records up to that time period "locked".

I'm sure that it has to tie in to the record locking property but I have no
idea how to go about it.

Can somebody help me out here please?

Thanks


 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q29zbW9zNzU=?=
Guest
Posts: n/a
 
      16th Nov 2005
I assume you have a field in your table that contains the date after which a
record should not be changed.

Here are 2 ways to do this. Both solutions assume that all your data entry
is done via a form.

Solution 1
Make sure to base your form on a query (or via a filter) to filter out all
records where the current date is greater or equal to the "Do-Not-Change"
date field. This won't work if you still need the users to be able to see
all the records whether or not they are to be 'locked".

Solution 2
Use the form's Current event to check if today's date is past the
"Do-Not-Change Date". If it is, then set the form's .AllowEdits to False.
This solution allows your users to still see the 'locked' records but can't
change anything.

e.g.
Private Sub Form_Current()
'Me.dtLock = field that contains date past which record is not to be
edited
'Only allow edits if today's date is than the value for dtLock
Me.AllowEdits = (Date < Me.dtLock)
End Sub

Private Sub Form_Open(Cancel As Integer)
'Set appropriate value for form's .AllowEdits property
Form_Current
End Sub

 
Reply With Quote
 
 
 
 
CJ
Guest
Posts: n/a
 
      16th Nov 2005
Brilliant, that should do it.

Thanks

"Cosmos75" <(E-Mail Removed)> wrote in message
news:6B91B5A3-A516-4B5B-84BF-(E-Mail Removed)...
>I assume you have a field in your table that contains the date after which
>a
> record should not be changed.
>
> Here are 2 ways to do this. Both solutions assume that all your data
> entry
> is done via a form.
>
> Solution 1
> Make sure to base your form on a query (or via a filter) to filter out all
> records where the current date is greater or equal to the "Do-Not-Change"
> date field. This won't work if you still need the users to be able to see
> all the records whether or not they are to be 'locked".
>
> Solution 2
> Use the form's Current event to check if today's date is past the
> "Do-Not-Change Date". If it is, then set the form's .AllowEdits to False.
> This solution allows your users to still see the 'locked' records but
> can't
> change anything.
>
> e.g.
> Private Sub Form_Current()
> 'Me.dtLock = field that contains date past which record is not to be
> edited
> 'Only allow edits if today's date is than the value for dtLock
> Me.AllowEdits = (Date < Me.dtLock)
> End Sub
>
> Private Sub Form_Open(Cancel As Integer)
> 'Set appropriate value for form's .AllowEdits property
> Form_Current
> End Sub
>



 
Reply With Quote
 
=?Utf-8?B?QWNjZXNzREIuSW5mbw==?=
Guest
Posts: n/a
 
      17th Nov 2005
"CJ" wrote:

> Brilliant, that should do it.
>
> Thanks

Slight tweak to handle when you are on a new record or if your date field is
Null.

Private Sub Form_Current()
If Me.NewRecord Then
Me.AllowEdits = True
Else
Me.AllowEdits = Not (Date >= Nz(Me.dtLock, Date + 1))
End If
End Sub

I created a sample and posted it on my website. Thank you for posting a
question that inspired that sample!
 
Reply With Quote
 
CJ
Guest
Posts: n/a
 
      18th Nov 2005
You are most welcome and thank you for the modification

CJ
"AccessDB.Info" <(E-Mail Removed)> wrote in message
news:928C4A39-7F0E-4B5D-A094-(E-Mail Removed)...
> "CJ" wrote:
>
>> Brilliant, that should do it.
>>
>> Thanks

> Slight tweak to handle when you are on a new record or if your date field
> is
> Null.
>
> Private Sub Form_Current()
> If Me.NewRecord Then
> Me.AllowEdits = True
> Else
> Me.AllowEdits = Not (Date >= Nz(Me.dtLock, Date + 1))
> End If
> End Sub
>
> I created a sample and posted it on my website. Thank you for posting a
> question that inspired that sample!



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Lock VBProject Programmatically without SendKeys (Note:- Idon't want to Unlock or crack the VBProject. Just want to Lock itProgrammatically) K Microsoft VB .NET 3 21st May 2010 04:55 PM
How to Lock VBProject Programmatically without SendKeys (Note:- Idon't want to Unlock or crack the VBProject. Just want to Lock itProgrammatically) K Microsoft Excel Programming 3 14th May 2010 12:51 AM
Lock and unlock records news.microsoft.com Microsoft Access Forms 1 17th May 2007 01:57 PM
how do i password protect an .xls file? how do i unlock it for automation. e.g. want to unlock and access a .xls from another .xls macro. Daniel Microsoft Excel Discussion 1 24th Jun 2005 01:20 AM
PowerPoint should have a Lock/Unlock button to lock the position . =?Utf-8?B?UGVpaHNpbg==?= Microsoft Powerpoint 2 3rd Feb 2005 02:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:10 PM.