Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 03-11-2004, 07:44 PM   #1
smyeong
Registered User
 
Join Date: Mar 2003
Location: Ipoh
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
smyeong
Unhappy New rule of controlling form entry

Hi, Does anybody know how to set a control whereby it can restrict users from editing the previous record line once entered, the particular column will be locked; no editing is allowed. But the next new record will be unlocked again for entry.

I tried to do myself but i have found an error when i edit previous row which is not ZERO . It stated runtime error 2166 "You can't lock a control while it has unsaved changes" Then, the following new entry which is auto-given ZERO can be unlock and work accordingly.

My code as like this :
Private Sub QTY_Change()
If "" & QTY <> 0 Then
QTY.Locked = True
If "" & QTY = 0 Then
QTY.Locked = False
End If
End If
End Sub


i did use event like BeforeUpdate or AfterUpdate or On_change instead ,but it failed somehow.

What could be that problem?

Thanks

smyeong is offline   Reply With Quote
Old 03-11-2004, 08:17 PM   #2
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 33,390
Thanks: 13
Thanked 4,124 Times in 4,056 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
If this applies to all fields, you could set the form's allow additions to yes and the allow edits to no. Or is that not what you're after?
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is online now   Reply With Quote
Old 03-11-2004, 11:17 PM   #3
smyeong
Registered User
 
Join Date: Mar 2003
Location: Ipoh
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
smyeong
New Control - Locking record after entered

Quote:
Originally Posted by pbaldy
If this applies to all fields, you could set the form's allow additions to yes and the allow edits to no. Or is that not what you're after?
Thanks anyway. My code has finally worked out.

Private Sub Form_Current()
DoCmd.RunCommand acCmdSaveRecord

If QTY <> 0# Then
QTY.Locked = True

Else
QTY.Locked = False
End If

End Sub

smyeong is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump




All times are GMT -8. The time now is 08:18 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World