Defaulting/locking fields on user input?

  • Thread starter BonnieW via AccessMonster.com
  • Start date
B

BonnieW via AccessMonster.com

Hello!

I'm trying to figure out whether it's possible to set up certain controls
(textboxes and comboboxes) to "lock in" certain inputs when the user checks a
box. (this sounds weird, I know, but we had a third-party app, no longer
supported, which did this).

So, for instance, we have the controls Date, Point, Species, and Behavior.
If someone went to Point 1 on 1/1/01, and saw five different species, each
doing different things, then we would want the user to be able to input the
point name and the date, indicate that they were to remain contstant til the
user changed them, then go and enter in species and behaivor information.
However, it's also likely that the user would have only one species at any
given point, or want to enter the data in reverse order (say, if they saw an
American Bittern at 8 different points, each with the same behavior, on one
or two different dates, they'd want to "lock" in the bittern and the behavior,
but not the point).

I could probably take this to another level of normalization, but I'm looking
to avoid that unless it would make things significantly "better"- the users
are used to being able to lock whichever fields they need to, thanks to the
previous app (as an unfortunate side effect, everything got dumped to one
table, making reporting & analysis rather a pain).

Any suggestions? Thanks in advance!
 
K

Klatuu

If you are saying you have some fields in your table you want the user to be
able to "lock" so that it cannot be edited now or in future sessions, Here is
an idea that will work, but will take some work.

For each of the fields in the table you want to lock/unlock, add a Yes/No
field to your table for it. Okay, that's the easy part.

Now we have to add the functionality to the form. Here is gets subjective,
based on how you would like the UI to work, but probably the easiest would be
to use a check box to lock the control. You would need one associated with
each Yes/No field. In the After Update event of the checkbox, change the
Enabled property to false and Locked property to True for the control the
field is bound to that you want locked. Something like:

Private Sub chkPointLock_AfterUpdate()
With Me
If .chkPointLock Then
.txtPoint.Enabled = False
.txtPoint.Locked = True
End If
End With
End Sub

Now, you would think you would also want to lock the checkbox so the control
can't be unlocked. The problem is, you can't disable or lock a control while
it has the focus. It this case, I don't see it as a problem. It will allow
the user to make changes until the record is saved.

Now, to keep it locked, use the Form Current event and lock and disable the
controls based on the check boxes:

With Me
If .chkPointLock = True Then
.txtPoint.Enabled = False
.txtPoint.Locked = True
.chkPointLock.Enabled = False
End If
Do the same for the other controls.

Also, if you have a field in a table named Date, you need to change it.
Date is an Access reserved word and using it as a name will cause problems.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top