Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Using Boolean to lock a record

Author  Topic 

Bishop
Starting Member

5 Posts

Posted - 2004-12-14 : 14:41:09
I want to be able to use a check box in a form that changes the enable/disable property of a record based on the Boolean status. Does anyone have a handy piece of code for this?

Thanks,

Bish

PETE314
Starting Member

37 Posts

Posted - 2004-12-29 : 11:51:48
Why not just do conditional formating on the form for each of the objects you wish to be disabled?

Select and use the expression

blnCheckBox = -1

(where blnCheckBox is the name of the object you are clicking on and off......and -1 is the value in a SQL bit type for the true value of a Checkbox.
Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2004-12-30 : 14:43:51
Bishop, in the onChange or onClick event of the checkbox you can put in module code to change the enabled/disabled properties of anything in the form. It would look something like this:

If chkDisableFormCheckBox.Value = True Then
Me.enabled = False
Else
Me.enabled = True
End If

---------------------------------------------------------------------------------
Infoneering: Information Technology solutions engineered to professional standards.
Go to Top of Page

jhermiz

3564 Posts

Posted - 2004-12-30 : 15:28:17
Bishop,

If you are talking about the contents of the record you must use the AllowEdits property...

If Me.chkBoxYourBool.Value = True then
Forms!frmYourForm.AllowEdits=False
else
Forms!frmYourForm.AllowEdits = True
end if

Jon


A new beat on the web -- http://www.web-impulse.com
Go to Top of Page

Bishop
Starting Member

5 Posts

Posted - 2005-01-07 : 16:53:26
I had 4 fields that I wanted to be disabled unless the user checked the box to enable them. Here is how I made it happen, and it seems to suit my purpose. Thank you all for your help.

Bishop

If (Me!chkMacroUpdt = True) Then
Me!TxtMacro.Enabled = False
Me!txtMacrodate.Enabled = False
Me!txtMacroRev.Enabled = False
Else
Me!TxtMacro.Enabled = True
Me!txtMacrodate.Enabled = True
Me!txtMacroRev.Enabled = True
End If
Go to Top of Page
   

- Advertisement -