Go Back   Access World Forums > Apps and Windows > Visual Basic

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 07-08-2009, 05:55 AM   #1
Vesubius_101
Registered User
 
Join Date: Jul 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Vesubius_101 is on a distinguished road
Need help to disable a field AFTER initial data entry

This probably sounds like a real newbie here. I have a date field on my main form that I want "disabled" after initial entry. For example, my accountants will go into the field called "Assigned Date" and type "May 31, 2009", next month, they will go back to the same record and change the date to "June 30, 2009" to make their stats look better. BTW, I'm using MS Access 2003.

I understand that by using VB code, I can adjust the properties of the field so that when the field is initially updated in a new document, it will allow for a date to be entered, but "AFTER" initial data entry, the field will remain disabled and no modifications will be allowed. I right click on the field to the the properties dialogue box. Under the "Event" tab, I see the line that says "After Update" and I believe that's where the VBA code would go. Does anyone know the code?

Vesubius_101 is offline   Reply With Quote
Old 07-08-2009, 06:04 AM   #2
DCrake
Administrator
 
DCrake's Avatar
 
Join Date: Jun 2005
Location: Burnley, Lancashire
Posts: 8,634
Thanks: 8
Thanked 310 Times in 208 Posts
DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light
Send a message via Skype™ to DCrake
Re: Need help to disable a field AFTER initial data entry

At the point when you control is being populated or on the Validate event check to see if there is a date in the field, and if so make the control .Enabled = False and .Locked = True

You can also use the Forms OnCurrent Event to check for population of controls, this way it will toggle the status depending on the contents.

David
__________________
David Crake


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
The Home of Simple Software Solutions.

O/S Windows XP (SP3) & Windows 7 64bit
Access 2003 (version 11.0)
Access 2007 (version 12.0)

Remember when posting sample databases you will get a better response if it is pre Access 2007 - not all people have it installed.
DCrake is offline   Reply With Quote
Old 07-08-2009, 10:26 AM   #3
Vesubius_101
Registered User
 
Join Date: Jul 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Vesubius_101 is on a distinguished road
Re: Need help to disable a field AFTER initial data entry

David, thanks for your post. This is much appreciated. Now, please bear with me. Let me clarify to see if I can follow you. If I right click on the text box, I see five tabs. One says "All" and under that I see "Validation Rule" and "Validation Text". Both lines are empty. If I continue to scroll down, I see "Enabled" has "yes" next to it, and "locked" has "no" next to it. Is this where I would adjust any of the properties?

Vesubius_101 is offline   Reply With Quote
Old 07-08-2009, 10:35 AM   #4
SOS
Registered Lunatic
 
SOS's Avatar
 
Join Date: Aug 2008
Location: Somewhere between here and there
Posts: 3,517
Thanks: 2
Thanked 58 Times in 53 Posts
SOS is a glorious beacon of light SOS is a glorious beacon of light SOS is a glorious beacon of light SOS is a glorious beacon of light SOS is a glorious beacon of light
Re: Need help to disable a field AFTER initial data entry

No, you would do it in code.

So, you would put this in the AFTER UPDATE event (in VBA Window) for the Assigned Date:

Code:
If Len(Me.[Assigned Date] & "") > 0 Then
   Me.[Assigned Date].Enabled = False
   Me.[Assigned Date].Locked = True
Else
   Me.[Assigned Date].Enabled = True
   Me.[Assigned Date].Locked = False
End If
And then you put that exact same code in the form's ON CURRENT event as well so it will do the check as you move from record to record.
SOS is offline   Reply With Quote
The Following 3 Users Say Thank You to SOS For This Useful Post:
Pauly78 (02-24-2015), tamalk (08-25-2016), True Blue (04-10-2018)
Old 04-10-2018, 07:16 AM   #5
True Blue
Newly Registered User
 
Join Date: Apr 2018
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
True Blue is on a distinguished road
Re: Need help to disable a field AFTER initial data entry

Another novice here. The code provided by SOS was exaclty what I was looking for and it worked perfectly. Thank you SOS.

True Blue is offline   Reply With Quote
Reply

Tags
access 2003 , after update , disable , text box , vb code

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Access Page: Autofill repeating fields with data from another field. abell86 General 0 05-26-2009 11:38 AM
Array to transfer field data from linked table? geekhunter Modules & VBA 1 10-09-2008 12:27 AM
record ids auto number problem. jason2885 Forms 4 07-03-2007 10:16 PM
Synchronisation error Voisine General 6 05-31-2007 01:42 PM
[SOLVED] Need blank form/subform - get runtime error MonicaS Forms 4 10-17-2000 10:04 AM




All times are GMT -8. The time now is 06:58 PM.


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

Sponsored Links

How to advertise

Media Kit


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