How can I enable / disable a checkbox in a table in a subform

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

Guest

I'm trying to enable a checkbox in a subform.
I use this code, but it enables the checkbox i all the rows, and not just
the row with focus.
fre.Enabled = True

I have also tryed Me!fre.Enabled = True but it work like the obove statement

How can I enable only the checkbox i the row with focus.
 
When you enable or disable a field in a continues form, it will applay to all
the records. Move the code to the on current event of the subform, that way
it will disable or enable the checkbox when you enter the record depend on
the criteria.

If criteria = true then
fre.Enabled = True
Else
fre.Enabled = False
End if
 
Or: Me.fre.Enabled = Criteria

Ofer said:
When you enable or disable a field in a continues form, it will applay to all
the records. Move the code to the on current event of the subform, that way
it will disable or enable the checkbox when you enter the record depend on
the criteria.

If criteria = true then
fre.Enabled = True
Else
fre.Enabled = False
End if
 
Thanks, but it does not seem to solve my problem.

I made a very simple testform (continues form) like this
field1 (text)
field2 checkbox (yes/no)
field3 checkbox (yes/no)

If field1 = 1 i want to enable field2 and disable field3 (just the row in
focus)
If field1 = 2 i want to disable field2 and ensable field3 (just the row in
focus)

Private Sub Form_Current()
If field1 = 1 Then
Me.field2.Enabled = False
Me.field3.Enabled = True
End If

If field1= 2 Then
Me.field2.Enabled = True
Me.field3.Enabled = False
End If

End Sub

I also tryed thís
field1_LostFocus() with the same code (and the same result it applays to all
the records.)
 
Create a function under the form
Function EnaDis()
If field1 = 1 Then
Me.field2.Enabled = False
Me.field3.Enabled = True
End If

If field1= 2 Then
Me.field2.Enabled = True
Me.field3.Enabled = False
End If

End Function

Call the function on the on current event of the sub form, and on the after
update event of Field1
 
Just returned from a short hollyday. I create the function calls it as you
suggest, but i still get the same result.
I will try to redesign my project to avoid using enable/disable checkboxes i
a continues form.
Thanks anyway
 
Back
Top