enable / disable check boxes based on combo box selection

riddicule123

Registered User.
Local time
Today, 13:20
Joined
May 27, 2015
Messages
29
hi me again,

im trying to enable/disable checkboxes based on a combobox selection for instance,

i make the selection in a combo box called terms and conditions. i want it then to only enable the business,domestic and summary check boxes for that type, with the onther check boxes staying disabled. is there a way this can be done through code like the statement "only enable if this letter type selection has been selected"

please help.

i'm not good with code lol
 
at the moment all the checkboxes are enabled for each new record and everything is bound to a feild from a table
 
What is the Default View of your form? Look in the property sheet of the form.
 
Ok. List out all the other checkboxes. And explain their relationship to the combo box.
 
ok so its here as follows
combo = application
check boxes = probate, extension, transfer request, change of ownership

combo = solar decs
checkboxes = appendix 5, appendix 6

combo = more info required
checkboxes = photo id, property type, amend mcs, no# of dials on meter, Mpan, last page of application, TIC, Meter Read, proof of purchase,

thats all the combo selections that are linked to a check box
 
Ok, you've got problems with your current table structure. If you require further assistance on that I would advise that you create a new thread in the Tables forum. Once addressed you won't be needing to enable/disable tonnes of checkboxes.

In any case, in order to disable/enable the checkboxes, a simple way for you is this:
Code:
Public Sub ChangeSelections(varComboValue As Variant)
    Dim blApplication As Boolean
    Dim blSolarDecs   As Boolean
    Dim blMoreInfo    As Boolean
    
    Select Case varComboValue
        Case "Application"
            blApplication = True
            
        Case "Solar Decs"
            blSolarDecs = True
            
        Case "More info required"
            blMoreInfo = True
    End Select
    
    Me.chkProbate.Enabled = blApplication
    Me.chkExtension.Enabled = blApplication
    Me.chkTransfer.Enabled = blApplication
    Me.chkOwnership.Enabled = blApplication
    
    Me.chkAppendix5.Enabled = blSolarDecs
    Me.chkAppendix6.Enabled = blSolarDecs
    
 [COLOR="Red"]   ' Complete the rest[/COLOR]
End Sub
* paste it into a Module
* in the After Update event of your combo box. As an example, you can call it this way:
Code:
ChangeSelections "Application"
 
Last edited:
thank you i have added all the code into a module but it comes up with an error invalid use of me.
 
thank you so i have done all this but now when i make a selection change in the combo boxes all the check boxes are now disabled and i cannot access any of them no matter what selection i make
 
Public Sub ChangeSelections(varLetter_Requested As Variant)
Dim blApplication As Boolean
Dim blSolarDecs As Boolean
Dim blMoreInfo As Boolean

Select Case varComboValue
Case "Application"
blApplication = True

Case "Solar Decs"
blSolarDecs = True

Case "More info required"
blMoreInfo = True

Case "Terms and Conditions"
blTerms = True

End Select

Me.Probate.Enabled = blApplication
Me.ExtensionApplication.Enabled = blApplication
Me.TansferRequest.Enabled = blApplication
Me.ChangeOfOwnership.Enabled = blApplication

Me.Appendix5.Enabled = blSolarDecs
Me.Appendix6.Enabled = blSolarDecs

Me.PhotoIdutilitybills.Enabled = blMoreInfo
Me.GenerationMeterread.Enabled = blMoreInfo
Me.Proofofpurchase.Enabled = blMoreInfo
Me.TIC.Enabled = blMoreInfo
Me.PropertyType.Enabled = blMoreInfo
Me.LastPageOfApplication.Enabled = blMoreInfo
Me.AmendMCS.Enabled = blMoreInfo
Me.MPAN.Enabled = blMoreInfo
Me.NoOfDialsOnMeter.Enabled = blMoreInfo

Me.Domestic_T_s___C_s.Enabled = blTerms
Me.Business_T_S___C_S.Enabled = blTerms
Me.Summary_Only.Enabled = blTerms
End Sub

Private Sub Letter_Requested_AfterUpdate()
ChangeSelections Me.Letter_Requested.Value
End Sub

there are no errors but everything is just greyed out on the check boxes
 
First, compare these two lines with what I wrote:
Code:
Public Sub ChangeSelections(varLetter_Requested As Variant)

Select Case varComboValue
Next look at the Select Case and determine what values you should be passing to the function.
 
No, varComboValue is "Application", "Solar Desks" and "More Info Required". You need to give the function a value that matches one of those values.

So one of these (depending on which control it is):
Code:
ChangeSelections "Application"
ChangeSelections "Solar Decs"
ChangeSelections "More Info required"
... sorry, I think I see what could have caused the confusion in the first instance.
 
so if i was to rewrite the code where would i put it, sorry im really basic at this and am trying to learn as i go
 
E.g. the After Update event of the Applications options frame:
Code:
ChangeSelections "Application"
And you need to fix what I highlighted in post #14.
 
so like this and im not sure what you meant in comment #14 . whats happening now is only 3 are enabled not matter what i pick which are dom terms/ busi terms and summary

Public Sub ChangeSelections(varComboValue As Variant)
Dim blApplication As Boolean
Dim blSolarDecs As Boolean
Dim blMoreInfo As Boolean
Dim blTerms As Boolean

Select Case varComboValue
Case "Application Pack"
blApplication = True

Case "Solar Decs"
blSolarDecs = True

Case "More Info Required"
blMoreInfo = True

Case "Terms and Conditions"
blTerms = True

End Select

Me.Probate.Enabled = blApplication
Me.ExtensionApplication.Enabled = blApplication
Me.TansferRequest.Enabled = blApplication
Me.ChangeOfOwnership.Enabled = blApplication

Me.Appendix5.Enabled = blSolarDecs
Me.Appendix6.Enabled = blSolarDecs

Me.PhotoIdutilitybills.Enabled = blMoreInfo
Me.GenerationMeterread.Enabled = blMoreInfo
Me.Proofofpurchase.Enabled = blMoreInfo
Me.TIC.Enabled = blMoreInfo
Me.PropertyType.Enabled = blMoreInfo
Me.LastPageOfApplication.Enabled = blMoreInfo
Me.AmendMCS.Enabled = blMoreInfo
Me.MPAN.Enabled = blMoreInfo
Me.NoOfDialsOnMeter.Enabled = blMoreInfo

Me.Domestic_T_s___C_s.Enabled = blTerms
Me.Business_T_S___C_S.Enabled = blTerms
Me.Summary_Only.Enabled = blTerms
End Sub

Private Sub Letter_Requested_AfterUpdate()
ChangeSelections "Application Pack"
ChangeSelections "Solar Decs"
ChangeSelections "More Info Required"
ChangeSelections "Terms and Conditions"
End Sub
 

Users who are viewing this thread

Back
Top Bottom