Continuous Form enable text box on current record (1 Viewer)

joeserrone

The cat of the cul-de-sac
Local time
Today, 00:19
Joined
Dec 17, 2006
Messages
164
Hello Everyone,
I have a Continous Form in Access to enter data, I have a textbox called "txbstartenter" thatI want to keep Disabled until the user doesn't press a button, then this textbox can become enabled and the user can edit information in it. I made the txbstartenter disabled by default and in the button I've placed the code:
with txbstartenter
.enabled = True
.value = now

However I realize that once I do that the txbstartenter box becomes enabled for new Records. How can I make this text box only enabled for the Current Record the user is working once they press this button and keep it disabled for new records?

Thanks
 

Fifty2One

Legend in my own mind
Local time
Yesterday, 21:19
Joined
Oct 31, 2006
Messages
1,412
In Continuous Forms a text box which is bound is bound to all of the records bound by the form. From what I think you are trying to do, if you have an unbound text box to turn on and off it will only be on the record which has the focus. You can transfer the data from the textbox to the records field under the AfterUpdate event.

Hello Everyone,
I have a Continous Form in Access to enter data, I have a textbox called "txbstartenter" thatI want to keep Disabled until the user doesn't press a button, then this textbox can become enabled and the user can edit information in it. I made the txbstartenter disabled by default and in the button I've placed the code:
with txbstartenter
.enabled = True
.value = now

However I realize that once I do that the txbstartenter box becomes enabled for new Records. How can I make this text box only enabled for the Current Record the user is working once they press this button and keep it disabled for new records?

Thanks
 

joeserrone

The cat of the cul-de-sac
Local time
Today, 00:19
Joined
Dec 17, 2006
Messages
164
Thanks for the suggestion, and what type of code do I need in my after update event to transfer this information to the table?
 

missinglinq

AWF VIP
Local time
Today, 00:19
Joined
Jun 20, 2003
Messages
6,423
All you need to do to set the enabled property back to No when moving to another record is:

Code:
Private Sub Form_Current()
 txbstartenter.Enabled = False
End Sub
 

missinglinq

AWF VIP
Local time
Today, 00:19
Joined
Jun 20, 2003
Messages
6,423
BTW,

...if you have an unbound text box to turn on and off it will only be on the record which has the focus.

is incorrect! Bound or unbound, what you do to a control on one record you do to that control on all records in a Continuous View Form! When you're talking about Enabling or Locking, as we are here, you simply reset the property when moving to another record, as my code above does.
 

joeserrone

The cat of the cul-de-sac
Local time
Today, 00:19
Joined
Dec 17, 2006
Messages
164
Is there a way to keep the old record enabled for editing and lock the new one?
 

missinglinq

AWF VIP
Local time
Today, 00:19
Joined
Jun 20, 2003
Messages
6,423
Not with what you've given us. You'd have to click your button again.

To only allow some records to remain editable and others not, you'd have to have a bound control, such as a checkbox, to indicate which records can be edited and which can't. Then set the enabled property accordingly, once again using the Form_Current event. To keep an entire record editable you'd use Me.AllowEdits and set it to True or False depending on the checkbox.

Another approach would be to set these properties, again in the Form_Current event, depending on whether or not some or all controls are populated.
 

joeserrone

The cat of the cul-de-sac
Local time
Today, 00:19
Joined
Dec 17, 2006
Messages
164
I took your suggestions and created a checkbox in the table and left it as False for default, then once the user presses a button the checkbox becomes enable. I also added a code to the on current of the form but still I can't get it to do what you suggested. Attached is the example of the database...... Let me know what you think!
 

Attachments

  • test.mdb
    388 KB · Views: 434

missinglinq

AWF VIP
Local time
Today, 00:19
Joined
Jun 20, 2003
Messages
6,423
In your Form_Current event, you need to tell Access not only what to do if RecordSelector is True, but what to do if it is False.

Code:
Private Sub Form_Current()

If Me.RecordSelector = True Then
  Me.txbStartEnter.Enabled = True
  Me.txbEndEnter.Enabled = True
Else   'If RecordSelector is not ticked
  Me.txbStartEnter.Enabled = False
  Me.txbEndEnter.Enabled = False
End If

End Sub
 

Users who are viewing this thread

Top Bottom