Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enabled textboxes

Status
Not open for further replies.

Bob500

Technical User
Aug 8, 2003
65
EU
Hi,

I have a tickbox called 'cinc' that when ticked enables a textbox called 'datecin'. But when I move across to anothe record the enabled status is lost and the text box becomes grayed out again. How do I keep the box enabled/disabled per record?

My code is:

Private Sub cinc_Click()
datecinc.Enabled = cinc.Value
End Sub

Thanks!
 
You could try on the On Current event
If cinc=true then
datecinc.Enabled = true
end if

Hope this helps
Hymn
 
on moving to another record, do you reset the tickbox? in that case you need to keep the tickbox checked.
 
Yeah the checkbox need to be unchecked as default. I hae tried the above code but if I tick it once all records have the textbox enabled.
 
try it on the AfterUpdate event on the check box

Hope this helps
Hymn
 
if you want to keep the box checked for that opening of the form, you could store the state in a variable and set it for all movements on that form, ie once checked, it's always set to checked when you move around records, otherwise your code is doing what you want it to, and resetting on every record movement.
 
Doesn't work, the textbox stays disabled.

The tickbox is a variable anyway isn't it? The code from Hymn sounds logical but I can't get it to work properly.
 
Hi Bob500

Is the cinc tickbox bound to a field in the table or query underlying your form? It needs to be so that your app can 'remember' whether it should be true or false for the current record.

Assuming your tickbox is bound, I agree with Hymn that you should place your enabling code in both the
Code:
AfterUpdate
event of the tickbox and in the
Code:
OnCurrent
event of the form.

Regards

Mac
 
I have put the code in hose places and it allows the textbox to become anabled, but if I untick it it does not go back to disabled.


Should I also have this in the code to do that:

If cinc=false then
datecinc.Enabled = false

Thanks :)
 
Hi Bob500

Yes, you need to describe the criteria for each state -
Code:
Me!cinc=False
to disable the textbox and
Code:
Me!cinc=True
to enable it.

Regards

Mac
 
Hey! I got it to work, but in a different way.

Private Sub cinc_Click()
datecinc.Enabled = cinc.Value
End Sub

Easy peasy, thanks for the help :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top