p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   VB How-To (http://p2p.wrox.com/forumdisplay.php?f=78)
-   -   Disable Check Boxes (http://p2p.wrox.com/showthread.php?t=31427)

sweet4511 July 12th, 2005 02:00 PM

Disable Check Boxes
 
Hello,

I need help with disabling one check box when another checkbox is selected on a form I built in Access?

BrianWren July 12th, 2005 03:30 PM

This is easiest if you use radio buttons (the round dealies with a dot in the middle), and put several of then into a frame. If one is selected, the others are automatically cleared.

sweet4511 July 13th, 2005 08:38 AM

Thank you for your help, but my customer requested checkboxes.


gbianchi July 13th, 2005 08:45 AM

hi there..

just put in the click event some code to disable the rest of the checks...
you have to do this for every check box...

HTH

Gonzalo

sweet4511 July 13th, 2005 09:29 AM

This is the code I came up with so far but its not working.

Private Sub GBP_Click()
If Me.GBP.Value = True Then
    Me.EURO.Enabled = False
 Else
    Me.EURO.Enabled = True
End If
End Sub

Private Sub EURO_Click()
If Me.EURO.Value = True Then
    Me.GBP.Enabled = False
 Else
    Me.GBP.Enabled = True

End If
End Sub



gbianchi July 13th, 2005 09:41 AM

hi..

you dont have to use the disable property, use the value property and set it to false.



HTH

Gonzalo

sweet4511 July 13th, 2005 10:22 AM

I switched the code and its still not working, maybe the rest of the code for this from will help.

Option Compare Database

Private Sub EURO_Click()
If Me.EURO.Value = True Then
    Me.GBP.Value = False
 Else
    Me.GBP.Value = False

End If
End Sub

Private Sub Form_Click()

End Sub

Private Sub Form_Close()
Forms![Invoice Navigator].List0 = ""
Forms![Invoice Navigator].List3 = ""
[Form_Invoice Navigator].Refresh
End Sub

Private Sub Form_Current()
'disable editing if contract is closed
If Me.Closed.Value = True Then
    Me.AllowEdits = False
    Me.lblContractClosed.Visible = True
Else
    Me.AllowEdits = True
     Me.lblContractClosed.Visible = False
End If

End Sub

Private Sub Form_Open(Cancel As Integer)
'disable editing if contract is closed
If Me.Closed.Value = True Then
    Me.AllowEdits = False
    Me.lblContractClosed.Visible = True
Else
    Me.AllowEdits = True
     Me.lblContractClosed.Visible = False
End If

'If EURO is chcked display EURO on invoice form
If Forms![Invoice Scanner].EURO = True Then
   Forms![Invoice Scanner]!InvSub.Form!CurPayIn = "EURO"


End If
' If GBP is checked on the contracts then display GBP on Invoice
If Forms![Invoice Scanner].GBP = True Then
    Forms![Invoice Scanner]!InvSub.Form!CurPayIn = "GBP"


End If

If Me.EURO.Value = True Then
    Me.GBP.Enabled = False
 ElseIf GBP.Value = True Then
    Me.EURO.Enabled = False
Else
    Me.EURO.Enabled = True
    Me.GBP.Enabled = True
End If



End Sub

Private Sub GBP_Click()
If Me.GBP.Value = True Then
    Me.EURO.Value = False
 Else
    Me.EURO.Value = False
End If
End Sub



gbianchi July 13th, 2005 10:26 AM

hi again...

what kind of error are you getting???

that will be more usefull than the code..

anyway remember that value property works with numbers, not boolean, you should be passing 0 to clear it (if my memory doesnt fail)...

HTH

Gonzalo

sweet4511 July 13th, 2005 10:31 AM

I don't get en error when I run the code.


gbianchi July 13th, 2005 10:36 AM

ok.. so try to explain your problem better..

you want to disable the check when the other is selected.. by disable you mean unchecked or grayed???

why the last code didnt work???

HTH

Gonzalo


All times are GMT -4. The time now is 03:04 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.