473,416 Members | 1,828 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,416 software developers and data experts.

ctl.Locked property error through VBA code.

Hello. I am using MS Access 2003 with XP/pro. I have a form that has the following properties set through the property sheet:

form: AllowAdditions = False
CartridgeID field: Locked = True

The AllowAdditions property is set so that the user can navigate through the records but not be able to begin a new record without clicking the New Record button. The ID field is locked so the user cannot change that field, while still being able to update/edit the rest of the record.

When the user clicks on the New Record button, I want the AllowAdditions property set to True and the Locked property for the ID field set to False.

I have tried this two ways through VBA code:

Expand|Select|Wrap|Line Numbers
  1. '1:
  2. Me.AllowAdditions = True
  3. Me.DataEntry = True
  4. Me!CartridgeID.Locked = False
  5.  
  6. '2:
  7. Me.AllowAdditions = True
  8. DoCmd.GoToRecord , , acNewRec
  9. Me!CartridgeID.Locked = False
  10.  
According to the Access help file and the Access website, either of these should work. However, I am getting the following error message every time it hits the Me!CartridgeID.Locked = False line of code:

"Run time error 438: Object doesn't support this property or method."

I am using the exact same syntax as is displayed in the examples from the help files and I do not understand why I am getting this error.

Any assistance you can provide will be greatly appreciated.
Dec 26 '07 #1
6 4478
missinglinq
3,532 Expert 2GB
First off, I'd trash the first code. DataEntry = True causes Access to create an empty recordset, and since you already have a recordset open based on your table or query, I wouldn't open a second one.

I'm guessing that CartridgeID is a required field, and maybe Access is balking because when a new record is invoked, it's locked. First thing I'd try is to place the unlocking code before going to a new record, and see if that solves the problem. Access is notorious for not actually hiliting the line causing the problem; it often hilites the immediately preceding line instead.
Expand|Select|Wrap|Line Numbers
  1.   Me.AllowAdditions = True
  2.   Me!CartridgeID.Locked = False
  3.  DoCmd.GoToRecord , , acNewRec
  4.  
Welcome to TheScripts!

Linq ;0)>
Dec 26 '07 #2
Thank you very much!
Dec 27 '07 #3
missinglinq
3,532 Expert 2GB
So that solved your problem?

Linw ;0)>
Dec 28 '07 #4
ADezii
8,834 Expert 8TB
Hello. I am using MS Access 2003 with XP/pro. I have a form that has the following properties set through the property sheet:

form: AllowAdditions = False
CartridgeID field: Locked = True

The AllowAdditions property is set so that the user can navigate through the records but not be able to begin a new record without clicking the New Record button. The ID field is locked so the user cannot change that field, while still being able to update/edit the rest of the record.

When the user clicks on the New Record button, I want the AllowAdditions property set to True and the Locked property for the ID field set to False.

I have tried this two ways through VBA code:

Expand|Select|Wrap|Line Numbers
  1. '1:
  2. Me.AllowAdditions = True
  3. Me.DataEntry = True
  4. Me!CartridgeID.Locked = False
  5.  
  6. '2:
  7. Me.AllowAdditions = True
  8. DoCmd.GoToRecord , , acNewRec
  9. Me!CartridgeID.Locked = False
  10.  
According to the Access help file and the Access website, either of these should work. However, I am getting the following error message every time it hits the Me!CartridgeID.Locked = False line of code:

"Run time error 438: Object doesn't support this property or method."

I am using the exact same syntax as is displayed in the examples from the help files and I do not understand why I am getting this error.

Any assistance you can provide will be greatly appreciated.
  1. As linq has suggested, get rid of the DataEntry = True line in the first block of code.
  2. As I see it, there is absolutely no reason why the second block of code should not work, even if [CartridgeID] is required, unless [CartridgeID] refers to a Control that does not support the Locked Property such as a Label. Can this possibly be the case?
Dec 28 '07 #5
missinglinq
3,532 Expert 2GB
That was the first thing that crossed my mind, too, ADezii, but the line

"The ID field is locked so the user cannot change that field"

made me assume that it was indeed, a textbox. Of course, stranger things have happened!

Linq ;0)>
Dec 28 '07 #6
ADezii
8,834 Expert 8TB
That was the first thing that crossed my mind, too, ADezii, but the line

"The ID field is locked so the user cannot change that field"

made me assume that it was indeed, a textbox. Of course, stranger things have happened!

Linq ;0)>
In this business that seems to be the norm (LOL)!
Dec 28 '07 #7

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

Similar topics

0
by: Tech | last post by:
In Visual Basic 6.0, the Locked property of a ComboBox control determined whether the text-box portion of the control could be edited. In Visual Basic ..NET, the Locked property prevents a control...
1
by: ano1optimist | last post by:
We've got users sharing a database where the front end apps reside on the local PC while the backend app is on the network. We have repeated problems where certain users lock the database causing...
2
by: Anastassios Giannaras | last post by:
Hello I have made an small access Database that is used by 4-5 people every day. Very often through the users get the message "Could Not Update; Currently Locked" There is an entry about that...
0
by: ethanj /personal/ | last post by:
We are using Access 2000 database, with the following settings. Tool > Options > Advance > Default Record Locking = Edited Record Open databases using record level locking = True Form...
2
by: Vinny Vinn | last post by:
On occasion a Network User Account gets locked out. This causes lots of problems as the account is used to run different programs. The programs fail when the user account is locked out. I would...
7
by: Andrea Moro | last post by:
I'm writing my first windows control library. A simple textbox with some numeric facilities. Well, there is a strange thing that happen. I want to add a locked property. As many other property,...
2
by: kafi | last post by:
Hi All; I am trying to find a way to make my locked control more visible on a web form. When I lock a control and display it on a web form (ASP.NET) the control is barely visible and it is hard...
0
by: Access Programming only with macros, no code | last post by:
ERROR MESSAGE: Could not update; currently locked by another session on this machine. BACKGROUND I have the following objects: Table1 - HO (which has about 51,000+ records) Table2 -...
0
by: cmrhema | last post by:
Hello I used to write the code text1.locked=true but to my utter surprise i could not find it in vb 2005 the locked property is displayed in property box but when i put down the code it does not...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.