Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 27th, 2006, 06:07 PM
Registered User
 
Join Date: Jun 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Lock Fields if record already exist

Hi,
I want to ask how can I lock certain fields if the record of a patient already exist?
I have a field named Patient_ID on my field and have a code on it.

Here's the Code :
Code:
----------------------------------------------------------------------

Dim PID As String
Dim stLinkCriteria As String
Dim rsc As DAO.RecordsetSet

rsc = Me.RecordsetClone

PID = Me.Patient_ID.Value
stLinkCriteria = "[Patient_ID]=" & "'" & PID & "'"
'Check PatientDetails table for duplicate PatientNumber

If DCount("Patient_ID", "Patient_info_TBL", stLinkCriteria) > 0 then

'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning Patient Number " _
& PID & " has already been entered." _
& vbCr & vbCr & "You will now be taken to the record.", vbInformation_
, "Duplicate Information"

'Go to record of original Patient Number

rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If

Set rsc = Nothing
----------------------------------------------------------------------


How can I lock the patient's last name & first name fields if the record already exist?
I want to prevent changing the patient's last name & first name field if they exist and how can I reset the last name & first name fields it's new record?


Pls help. Thanks...

Jim


 
Old January 30th, 2006, 06:03 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Hi, Jim.

You'll find that each textbox has a .Locked property, e.g. Me.txtMyTextBox.Locked = True, you can turn on and off by code. You can also turn the record manipulation for the entire record on and off by using Me.AllowEdits, Me.AllowDeletions, and Me.AllowAdditions. These apply to the form.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old February 2nd, 2006, 03:07 PM
Registered User
 
Join Date: Jun 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Greg... I appreciate it..






Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot create record, directory exist auxiora_nemesis PHP Databases 1 April 13th, 2008 11:04 PM
Insert where record doesn't already exist Neal SQL Server 2000 3 February 4th, 2008 10:09 AM
record exist or not keyvanjan Classic ASP Basics 2 May 5th, 2006 11:39 AM
Return a record that doesn't exist in a table? Unregistered SQL Server 2000 4 May 3rd, 2006 01:27 AM
Record source ... does not exist tunsted Access 2 April 1st, 2004 10:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.