Debug help

  • Thread starter Thread starter Matt Howard
  • Start date Start date
M

Matt Howard

I don't know if this is the right group but I would
appreciate any advice. I'm not that familiar with VBA (or
VB for that matter), but I'm trying to set an object
property so that when a check box is checked then a text
box is enabled and if it is unchecked the box is
disabled. Here is my code:

Private Sub VanTrained_Click()
If Forms!frmDriverInfo2!VanTrained = "Yes" Then
Forms!frmDriverInfo2!VanCertDate.Enabled = "Yes"
Else
Forms!frmDriverInfo2!VanCertDate.Enabled = "No"
End If
End Sub

It debugs the Forms!... after the Else and says data
mismatch.

Any suggestions? Thanks, Matt
 
Private Sub VanTrained_Click()
If Forms!frmDriverInfo2!VanTrained = "Yes" Then
Forms!frmDriverInfo2!VanCertDate.Enabled = "Yes"
Else
Forms!frmDriverInfo2!VanCertDate.Enabled = "No"
End If
End Sub

Enabled is a boolean property, so it has to be set to True or False. I
guess the same is true for the VanTrained value if it refers to a checkbox.

And I would consider using the Control_AfterUpdate event, which only fires
when the control is changed, as well as the Form_Current to set it up as
soon as the form lands on a record.

HTH


Tim F
 
Back
Top