Activating textboxes with tick boxes

A

alexr114

What code can I use to activate a certain textbox if a tickbox is clicked on
and then if its taken out deactivate it?
 
B

Barry Gilbert

In the AfterUpdate event of the checkbox, put this code:

Me.txtMyTextbox.Enabled = (Me.chkMyCheckbox.Value = -1)

Barry
 
N

Nick 'The database Guy'

Hi Barry,

Try using:

Me.txtMyTextBox.Enabled = Me!chkMyCheckBox

Good luck,

Nick
 
K

Klatuu

Change the -1 to True
Me.txtMyTextbox.Enabled = (Me.chkMyCheckbox.Value = True)

Barry,
you are a good guy and I respect you abilities; however, you constant use of
literals where intrinsic constants are available really bothers me. Code is
so much easier to read when you use them.
 
B

Barry Gilbert

Nick and Klatuu,
Here's my revised suggestion:

If Me.chkMyCheckbox.Value = CBool(CStr(1 * -1)) Then
If Me.txtMyTextBox.Enabled = CBool("Today" = "Yesterday") Then
Me.txtMyTextbox.Enabled = CBool("hippopotamus" = "hippopotamus")
End If
Else If Me.chkMyCheckbox.Value = CBool(CStr(CInt("False"))) Then
If Me.txtMyTextbox.Enabled = CBool("Yesterday" = "Tomorrow") Then
Me.txtMyTextbox.Enabled = Not(CBool(CStr(Me.chkMyCheckbox.Value)))
End If
End If

:)
Barry
 
G

Greg Hall

I've tried the following:

Private Sub chkPmt_Bump_AfterUpdate()

Me.txtOrig_Pmt.Enabled = (Me.chkPmt_Bump.Value = True)

End Sub

However, I noticed that if I check the box for record 1, all of the
remaining text boxes are enabled. How do you restrict the text box to be
enable for that specific record?
 
B

Barry Gilbert

Greg Hall said:
I've tried the following:

Private Sub chkPmt_Bump_AfterUpdate()

Me.txtOrig_Pmt.Enabled = (Me.chkPmt_Bump.Value = True)

End Sub

However, I noticed that if I check the box for record 1, all of the
remaining text boxes are enabled. How do you restrict the text box to be
enable for that specific record?

Unfortunately, in a continuous form, most properties of a contol in a form's
detail section apply to all instances of that control. The only exception is
Conditional Formatting, which can only be used for font color, back color,
etc.

The workaround is to put a few key fields in the detail section and other
fields in the form's header or footer section. Then you have more control
over properties in those controls. To do this, though, have to write a little
code in the form's OnCurrent event to fill the header/footer values.

Barry
 
N

Nick 'The database Guy'

Barry,

Don't take the piss!


Barry said:
Nick and Klatuu,
Here's my revised suggestion:

If Me.chkMyCheckbox.Value = CBool(CStr(1 * -1)) Then
If Me.txtMyTextBox.Enabled = CBool("Today" = "Yesterday") Then
Me.txtMyTextbox.Enabled = CBool("hippopotamus" = "hippopotamus")
End If
Else If Me.chkMyCheckbox.Value = CBool(CStr(CInt("False"))) Then
If Me.txtMyTextbox.Enabled = CBool("Yesterday" = "Tomorrow") Then
Me.txtMyTextbox.Enabled = Not(CBool(CStr(Me.chkMyCheckbox.Value)))
End If
End If

:)
Barry
 
B

Barry Gilbert

Nick 'The database Guy' said:
Barry,

Don't take the piss!

I don't know what that means, but I guess it wasn't clear that I was just
trying to have a little fun. I accept both bits of feedback graciously.

Barry
 
N

Nick 'The database Guy'

Time and a place Barry, time and a place.
Barry said:
I don't know what that means, but I guess it wasn't clear that I was just
trying to have a little fun. I accept both bits of feedback graciously.

Barry
 
Top