473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Problem - Lock records in continuous form except new and edited record.

I have the following setup:
Table containing record for transactions with products – in and out of a warehouse.
Continuous form for entering transaction information.
I have filtered the form to show only records from today and yesterday.
I locked old records in the current event of the form
Expand|Select|Wrap|Line Numbers
  1.  Private Sub Form_Current()
  2.     Me.AllowEdits = Me.NewRecord
  3. End Sub
  4.  
Everything works fine until the current record loses focus (I made a check if the user clicks on locked record a message show “You Can’t Edit saved records” ). When the current record loses focus it is locked and the user can’t finish filling in all needed information.
I tried, after the message pops up to move the focus to the new record and it works, but the focus is moved to the current column new record and I have a series of checks that prevent the user to fill in a filed in the new record before filling in information in the previous field. This leads to two messages every time the user clicks on saved record – one “You Can’t Edit saved records” and one “You have to fill in the previous field”.

How can I stop the current record from locking after the “You Can’t Edit saved records” message pops up or set the focus to the first field in the new record?
Nov 3 '10 #1

✓ answered by Stewart Ross

Hi. Users often make minor mistakes when entering data, and need to edit the record they just entered. They can't do this if they are prevented from doing so by having confirmed that they wanted to save the current record.

To allow for editing minor errors I add a date/time field called DateCreated to the table concerned, and set its DefaultValue property to Now() to record the current date and time automatically when the record is inserted by Access.

I then use the On Current event of the form to test whether the value of the current date and time is greater than the value of the DateCreated field by a particular threshold. I allow an hour in some cases (a value difference of 0.04 between the original date and time and the current one).

If the time difference is greater than the threshold of, say, an hour then AllowEdits is set to false. I also have visual confirmation of edit status on the form, to leave the user in no doubt that the record is read-only.

I also use a similar technique in a larger application where the edit threshold for records is expressed in days rather than hours or minutes. In this case the threshold is stored as a value in a system parameters table, so that administrators can change the 'keep editable' threshold if required (from 7 days to 1 day, for example).

-Stewart

5 6165
jimatqsi
1,271 Expert 1GB
Try adding this code to the OnCurrent event for the form:
Expand|Select|Wrap|Line Numbers
  1. me!fieldname.setfocus
Or you could put that code right after the message
“You Can’t Edit saved records”

Jim
Nov 4 '10 #2
I have tried this but it didn't work as i need it.
I have sorted this problem by adding additional field type Yes/No - hidden for the user. By default is set to No (false) after the save record button i pressed the current record is saved and the field is set to Yes (true). This way i can control when the message is displayed and when not.
Tx anyway for your help.
Nov 4 '10 #3
Stewart Ross
2,545 Expert Mod 2GB
Hi. Users often make minor mistakes when entering data, and need to edit the record they just entered. They can't do this if they are prevented from doing so by having confirmed that they wanted to save the current record.

To allow for editing minor errors I add a date/time field called DateCreated to the table concerned, and set its DefaultValue property to Now() to record the current date and time automatically when the record is inserted by Access.

I then use the On Current event of the form to test whether the value of the current date and time is greater than the value of the DateCreated field by a particular threshold. I allow an hour in some cases (a value difference of 0.04 between the original date and time and the current one).

If the time difference is greater than the threshold of, say, an hour then AllowEdits is set to false. I also have visual confirmation of edit status on the form, to leave the user in no doubt that the record is read-only.

I also use a similar technique in a larger application where the edit threshold for records is expressed in days rather than hours or minutes. In this case the threshold is stored as a value in a system parameters table, so that administrators can change the 'keep editable' threshold if required (from 7 days to 1 day, for example).

-Stewart
Nov 5 '10 #4
Tank you Stewart for your reply. I actually have such field in my table but didn’t think of using it this way.
Thank you i will include this mechanic in my form.
Nov 5 '10 #5
jimatqsi
1,271 Expert 1GB
Stewart, that's a nice solution, thanks.

Jim
Nov 5 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Kathy | last post by:
What is the standard technique for handling the fields in the following scenario on a continuous form? Multiple Divisions. Each Division has multiple Buildings. Each Building has a Supervisor. ...
20
by: Robert | last post by:
Need some help to stop me going around in circles on this one.... Have a nested subform (subform2) which simulates a continuous form for the record on the parent subform. Subform2 has rows of...
3
by: S P Arif Sahari Wibowo | last post by:
Hi! I would like to make an editable continous form, where most fields will be from table A and editable, except 1-3 fields are a glimpse into table B and uneditable. Table A relate to table B...
1
by: Bill | last post by:
Problem: Combo box data disappears from view when a requery is done See "Background" below for details on tables, forms & controls On a form, I want to use the setting of bound combo box C1...
3
by: ApexData | last post by:
I am using a continuous form for display purposes. Above this form, a single record is displayed so that when the user presses my NewButton they can enter a NewRecord which gets added to the...
5
by: ApexData | last post by:
I have a Continuous SubForm on a TabPage. Above the ContinuousForm is a "box of fields" I use to display the entire record that the focus is on. When one points to a record using the...
3
by: eighthman11 | last post by:
Using Access 2000. I have a continuous form which for simplicity sack has two fields Social Security Number and Last Name. In the header of the continuous form I have a textbox where you can...
13
by: eighthman11 | last post by:
using Access 2003 and sql server version 8.0 Hey everyone. Created a text box where the user types in an Inventory number and it takes them to that inventory number on the contimuous form. The...
6
by: jmartmem | last post by:
Greetings, I have an Access 2002 continuous form called "Project Update Form" in which users can update project values presented in a series of combo boxes and text boxes. Three of the combo...
7
by: ggfota | last post by:
I have problem creating Access (Continuous) Form with indepenent CheckBox for each record. The user should be able to select records that will be processed by VBA based on ChceckBox value. When I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.