VB question, Combo box enables or disables others

  • Thread starter Thread starter Clay
  • Start date Start date
C

Clay

I am new to VB programming so please be patient, I have a form with several
boxes related to crminal involvement and ithe first box ask if they have had
any criminal involvement. When the answer is yes then additonal questions and
combo boxes are enabled, when no they are disabled. (i have this part working)

My question is how can I place (or have access) place a 0 into the table for
each box when it is disabled, otherwide my table contains null values and
that creates other problems?

Here ismy code

Private Sub cmbCriminal_Change()
cboLegalCrime.Enabled = (cmbCriminal.ListIndex() = 0)
cboLegalConvProb.Enabled = (cmbCriminal.ListIndex() = 0)
cboLegalConvCorr.Enabled = (cmbCriminal.ListIndex() = 0)
cboLegalConPar.Enabled = (cmbCriminal.ListIndex() = 0)
cboLegalNone.Enabled = (cmbCriminal.ListIndex() = 0)
cboLegalYes.Enabled = (cmbCriminal.ListIndex() = 0)
cboLegalUns.Enabled = (cmbCriminal.ListIndex() = 0)
End Sub
 
Additional steps added to your code:


Private Sub cmbCriminal_Change()
cboLegalCrime.Enabled = (cmbCriminal.ListIndex() = 0)
cboLegalConvProb.Enabled = (cmbCriminal.ListIndex() = 0)
cboLegalConvCorr.Enabled = (cmbCriminal.ListIndex() = 0)
cboLegalConPar.Enabled = (cmbCriminal.ListIndex() = 0)
cboLegalNone.Enabled = (cmbCriminal.ListIndex() = 0)
cboLegalYes.Enabled = (cmbCriminal.ListIndex() = 0)
cboLegalUns.Enabled = (cmbCriminal.ListIndex() = 0)
cboLegalCrime.Value = Nz(cboLegalCrime.Value, 0)
cboLegalConvProb.Value = Nz(cboLegalConvProb.Value, 0)
cboLegalConvCorr.Value = Nz(cboLegalConvCorr.Value, 0)
cboLegalConPar.Value = Nz(cboLegalConPar.Value, 0)
cboLegalNone.Value = Nz(cboLegalNone.Value, 0)
cboLegalYes.Value = Nz(cboLegalYes.Value, 0)
cboLegalUns.Value = Nz(cboLegalUns.Value, 0)

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top