Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / March 2008

Tip: Looking for answers? Try searching our database.

Prohibiting edits to data in a text box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mjg - 18 Mar 2008 20:16 GMT
This seems like it should be simple:

Using a form property sheet Access allows me to specify "Allow Edits",
"Allow Additions", and "Allow Deletions", but these pertain to entire
records.  I can't figure out how to "Allow Additions" and not "Allow Edits"
to just one specific control on my form.  If I use the "Lock" feature then
the user can't populate the field of a new record.  

Any tips?

-mjg
Beetle - 18 Mar 2008 20:31 GMT
In the forms current event

If Me.NewRecord Then
   Me.ControlName.Locked = False
Else
   Me.ControlName.Locked = True
End If
Signature

_________

Sean Bailey

> This seems like it should be simple:
>
[quoted text clipped - 7 lines]
>
> -mjg
mjg - 18 Mar 2008 20:40 GMT
Beetle - thanks for quick reply.

This solution works, but it's not ideal - here's why.  
The very first field on my form is a Parcel ID number which is required.  
Once that number is entered the first time, I would like it to be locked.  
Here's the catch: there are a number of other fields on the form that, in
practice will be populated over the course of time.  Some may be filled in
right away, when the Parcel ID number is first entered, some may be filled in
weeks later, and some may need to be edited several years later.  The forms
current event affects all of these controls and I would like it to only
affect the first one (Parcel ID).

- mjg

> In the forms current event
>
[quoted text clipped - 15 lines]
> >
> > -mjg
Douglas J. Steele - 18 Mar 2008 20:54 GMT
But Beetle's suggestion is strictly locking a single control!

Based on what you've added, you'd probably want

If Me.NewRecord Then
   Me.ParcelID.Locked = False
Else
   If Len(Me.ParcelID & vbNullString) > 0 Then
     Me.ParcelID.Locked = True
   Else
     Me.ParcelID.Locked = False
   End If
End If

Even simpler is

Me.ParcelID.Locked = Not Me.NewRecord And (Len(Me.ParcelID & vbNullString) >
0)

Note that you'll likely want to introduce some means of unlocking the field
in case an error needs to be corrected.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Beetle - thanks for quick reply.
>
[quoted text clipped - 33 lines]
>> >
>> > -mjg
mjg - 19 Mar 2008 15:17 GMT
You were right, Beetle's solution worked fine.

I'm new to VB and don't understand some of the code below
("Len...vbNullString") so I just stuck with the simple solution.

Thanks for your help,
-mjg

> But Beetle's suggestion is strictly locking a single control!
>
[quoted text clipped - 55 lines]
> >> >
> >> > -mjg
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.