Making data non-updatable

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with a bound combo box in which staff selects an option from
the list. Once data is entered into the field, I want to make it
non-updatable (ie. can't edit). I'm looking for the "once it is entered, it
is not updatable).

I've looked at locking the control but that does not work.
I can't make it read only since it could not have initial data entered.

Any suggestions are appreciated! Thanks!
 
I have a form with a bound combo box in which staff selects an option from
the list. Once data is entered into the field, I want to make it
non-updatable (ie. can't edit). I'm looking for the "once it is entered, it
is not updatable).

I've looked at locking the control but that does not work.
I can't make it read only since it could not have initial data entered.

Any suggestions are appreciated! Thanks!

How about this? In the After Update event of the combo ...

First, set the focus to the next control in the tab order, then set
the control to not enabled. In the the forms On Current event set the
combo back to enabled.

Me.nextcontrol.SetFocus
Me.cboBox.Enabled = False

Note: you need to set the focus to another control before un-enabling
the combo. And by making the control not enabled vs. locked it is
evident to the user what is going on.

- Jim
 
Alicia said:
I have a form with a bound combo box in which staff selects an option from
the list. Once data is entered into the field, I want to make it
non-updatable (ie. can't edit). I'm looking for the "once it is entered, it
is not updatable).

I've looked at locking the control but that does not work.
I can't make it read only since it could not have initial data entered.

Any suggestions are appreciated! Thanks!

Why doesn't locking the control work? It should. Where are you executing the
code to change the Locked setting? It should be in the AfterUpdate event of the
control as well as in the current event of the form.
 
The code goes in the After Update event of the combo box.

Do this; in design mode of the form, Right Click on the combo box and
select properties. In the properties window select the Event tab. Look
for the After Update event. Select it and click the [...] button on
the right. If you get a window asking which builder to use select the
Code Builder. This will take you to the forms module and the event
that you have selected. This is where the code goes.

"Me" is a keyword that refers to the form.

Take some time and look up some of this stuff in help. The time will
be well worth it.

- Jim
 
Jim, thanks so much for your advice. I have played with your concept with
some success and now have a couple of issues/question:

1. The combo box does become enabled as long as the control that the focus
moves to is enabled and visable. Is this correct (I created a control that
doesn't do anything and was planning on hiding it...but can figure out a way
to hide is with some other plan).

2. When I re-access the form with these controls/data, the previous
disabled combo box is again re-enabled where the data can be changed. I want
it to stay disabled. I tried to use some code and expressions but don't
know what I am doing.

3. Lastly, this is done on the After Update property where I already had a
macro attached to it. How/where do I add this macro to allow it to continue
to run after this disable process?

Thanks again for all of your help! I feel so proud that I got the combo box
to disable. Never used a module before. Scary :)
Alicia
 
Alicia, comments in line ...

Jim, thanks so much for your advice. I have played with your concept with
some success and now have a couple of issues/question:

1. The combo box does become enabled as long as the control that the focus
moves to is enabled and visable. Is this correct (I created a control that
doesn't do anything and was planning on hiding it...but can figure out a way
to hide is with some other plan).

That's correct, and logical if you think about it. You could have an
exit form button to set focus to.
2. When I re-access the form with these controls/data, the previous
disabled combo box is again re-enabled where the data can be changed. I want
it to stay disabled. I tried to use some code and expressions but don't
know what I am doing.
While I don't know the purpose of the form, generally what you would
need to do to deal with the issue is to use some sort of flag on the
record.

For example you might have a Yes/No field called ItemEntered. You
would set that to true when the combo item is selected. And then when
the record is accessed again use the forms On Current event to set the
combos enabled property appropriately.

Me.cboBox.Enabled = Not Me.ItemEntered

This expression would set the enabled property to False when
ItemEntered is True.
3. Lastly, this is done on the After Update property where I already had a
macro attached to it. How/where do I add this macro to allow it to continue
to run after this disable process?

Run the macro in code. Use...
DoCmd.RunMacro "My Macro"

Followed by the code to deal with the combo box.
Thanks again for all of your help! I feel so proud that I got the combo box
to disable. Never used a module before. Scary :)
Alicia

Your'e welcome, and good for you. It becomes less scary over time. Why
in 3 or 4 years you won't give it a second thought ;-)

- Jim
 
Back
Top