Disable checkbox if that record already has one checked.

spokaneneon

New member
Local time
Yesterday, 20:05
Joined
Oct 7, 2011
Messages
8
Hello guys!
What I am trying to acomplish today is some sort of way that when a user opens the new form (which opens at a new record) his form is blank. However, if an entry already exists in my table, if that person tries to enter a new record, I want it to disable other checkboxes if that one already exists. So basically, entering a new record is fine to enter, but if they try to enter a new one, then it will disable them entering in another record with the same checkbox. I would like it to be grayed out, or already checked.

Any way to make this happen?
 

Attachments

  • untitled.JPG
    untitled.JPG
    88.4 KB · Views: 195
You may want to handle the Current event of the form object--which fires whenever the form loads a record--and then set the Enabled property of the Checkbox. When Enabled is false the control appears greyed out. Sample code...
Code:
private sub Form_Current()
  If me.chkSomeData = True Then
    me.chkSomeData.enabled = False
  else
    me.chkSomeData.enabled = True
  end if
end sub
If you understand what's going on here, a simpler way to express the same thing is...
Code:
private sub Form_Current()
[COLOR="Green"]  'the enabled status is always just the opposite of the value of the control[/COLOR]
  Me.chkSomeData.Enabled = not me.chkSomeData
end sub
Cheers,
 

Users who are viewing this thread

Back
Top Bottom