Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 10th, 2007, 06:28 PM
Registered User
 
Join Date: Jun 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Disable checkbox until a selection is made

I'm trying to set up an Access 2003 form with a number of combo boxes, a checkbox and a command button. I'd like to set up the checkbox so that it is enabled only after the user makes a selection from each of the combo boxes. The command button will be enabled only if the checkbox is checked. Optimally, I'd like to have the checkbox greyed out until it's available. Anyone have a solution for something like this? This is the sub I've been calling in Form_Load and AfterUpdates:

Private Sub EnableCheck()

If Me.cbo1 = Null Or Me.cbo2 = Null Or Me.cbo3 = Null Or Me.cbo4 = Null Then
   Me.chkConfirm.Enabled = False

Else
   Me.chkConfirm.Enabled = True

End If

End Sub
 
Old June 11th, 2007, 04:57 AM
Friend of Wrox
 
Join Date: Apr 2006
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What I think you should do is:

Put the enabled property of the check box to false first.

I'm guessing the combo boxes or not cascading? If yes, only put the code on the last one, else put it on every combo box:

private sub combo afterupdate

if (isnull(me.cbo1) or me.cbo1 = "") AND (isnull(me.cbo2) or me.cbo2 = "") AND (isnull(me.cbo3) or me.cbo3 = "") AND (isnull(me.cbo4) or me.cbo4 = "") then
   me.chkConfirm.enabled=false
else
   me.chkconfirm.enabled=true
end if

end sub

this should enable the check box if an input has been made in every combo box (if I did not forget anything...)

To enable the command button do the following:
Put the enabled property to false
on the afterupdate event of the check box:

if me.chkconfirm = yes then
   me.commandbutton.enabled = true
else
   me.commandbutton.enabled = false
end if

Think this should do it...

 
Old June 12th, 2007, 11:59 AM
Authorized User
 
Join Date: Mar 2007
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The way I have always tested for a selection having been made in a combo box is like this:

If cmbMyCombo.ListIndex = -1 Then
    MsgBox "Please select a value in MyCombo", vbExclamation + vbOkOnly, "Entry Needed"
Else
    ' Ok to carry on...
End If

Hope that helps...

 
Old January 12th, 2008, 01:07 AM
Registered User
 
Join Date: Jan 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to biscuit.cracker
Default

I have a form named "SelectSite" inside it I have a button named "OK" to enable/disable by check/uncheck a checkbox named "HideSelectSiteForm".

First of all..create event "onOpen" for this form then put this:

Me.OK.Enabled = False

Then on event property for this checkbox I put eventprocedure at "OnClick" Then...put script below


Private Sub HideSelectSiteForm_Click()
Me.OK.Enabled = True
    With Me.OK
        If Me.HideSelectSiteForm.Value = 0 Then ' If cleared.
            .Enabled = False ' Disable button.
        Else ' If checked.
            .Enabled = True ' Enable button.
        End If
    End With
End Sub




Thats it...





Similar Threads
Thread Thread Starter Forum Replies Last Post
Disabling Selection Of CheckBox pady123 Pro Visual Basic 2005 1 April 8th, 2008 05:16 AM
checkbox selection in a webform vinodonline2000 ASP.NET 2.0 Basics 1 July 27th, 2007 05:52 AM
enable/disable textfields based on radio selection carrie.mims Javascript How-To 5 December 8th, 2006 05:41 AM
Excel Checkbox selection thru C# imsuneeta General .NET 1 June 16th, 2005 02:07 AM
check if radio button list selection made jtyson Classic ASP Basics 1 July 3rd, 2004 12:34 AM





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