Need help to disable a field AFTER initial data entry (1 Viewer)

Vesubius_101

New member
Local time
Today, 11:54
Joined
Jul 7, 2009
Messages
2
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?
 

DCrake

Remembered
Local time
Today, 15:54
Joined
Jun 8, 2005
Messages
8,632
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
 

Vesubius_101

New member
Local time
Today, 11:54
Joined
Jul 7, 2009
Messages
2
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?
 

SOS

Registered Lunatic
Local time
Today, 08:54
Joined
Aug 27, 2008
Messages
3,517
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.
 

True Blue

New member
Local time
Today, 08:54
Joined
Apr 10, 2018
Messages
1
Another novice here. The code provided by SOS was exaclty what I was looking for and it worked perfectly. Thank you SOS.
 

Users who are viewing this thread

Top Bottom