This is so simple, why isn't it working???

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hello all,
I know it's something stupid I'm overlooking somewhere...
I have a main form frm_PBT with many text fields and comboboxes on it.
If a record comes up with cmbGroup,cmbCompany,cmbYear or cmbPeriod already
populated I wanted those fields to be disabled...

Small sample:

Private Sub Form_Current()
If Me.cmbGroup.Value = True Then
Me.cmbGroup.Enabled = False
Else: Me.cmbGroup.Enabled = True

End If

End Sub

What I'm expecting to happen is when the form opens or the record changes
the field should be disabled.... am I wrong? Nothing happens.
Can someone help?
 
TimT said:
hello all,
I know it's something stupid I'm overlooking somewhere...
I have a main form frm_PBT with many text fields and comboboxes on it.
If a record comes up with cmbGroup,cmbCompany,cmbYear or cmbPeriod
already populated I wanted those fields to be disabled...

Small sample:

Private Sub Form_Current()
If Me.cmbGroup.Value = True Then
Me.cmbGroup.Enabled = False
Else: Me.cmbGroup.Enabled = True

End If

End Sub

What I'm expecting to happen is when the form opens or the record
changes the field should be disabled.... am I wrong? Nothing
happens.
Can someone help?

Is cmbGroup bound to a Yes/No field? If not, it's fairly unlikely that
its value will be equal to True. Maybe what you want is this:

If IsNull(Me.cmbGroup.Value) Then
Me.cmbGroup.Enabled = True
Else
Me.cmbGroup.Enabled = False
End If

.... which could be simplified to this:

With Me.cmbGroup
.Enabled = IsNull(.Value)
End With
 
Try this instead:

If IsNull(Me.cmbGroup) Then
Me.cmbGroup.Enabled = True
Else
Me.cmbGroup.Enabled = False
End If
 
Well, the value is not true. The value is whatever is entered in the field.

You'd want to say, if the value is not null or if it is not "".
 
Back
Top