Trying to disable a command button in visual basic

  • Thread starter Thread starter lizza
  • Start date Start date
L

lizza

I have a command button located in the form [IHS to Categorize] that I am
trying to disable when the form [DistinctMSNNum] returns null for the record
[MSM Number]
If I try it with a record of the [IHS to Categorize] form it works but not
when i use a record in another table.. Any suggestions??

Thanks in advance

Private Sub Form_Current()

Dim test As String

test = "Forms![DistinctMSNNum]![MSM Number]"

'If IsNull([IHS Description]) Then


If IsNull(test) Then

Me.Command39.Enabled = False

Else

Me.Command39.Enabled = True

End If

End Sub
 
Try:

Private Sub Form_Current()

If IsNull(Forms![DistinctMSNNum]![MSM Number]) Then
Me.Command39.Enabled = False
Else
Me.Command39.Enabled = True
End If

End Sub

or, more consise,

Private Sub Form_Current()

Me.Command39.Enabled = Not IsNull(Forms![DistinctMSNNum]![MSM Number])

End Sub
 
Thank you so much Doug! I'll try it out

Douglas J. Steele said:
Try:

Private Sub Form_Current()

If IsNull(Forms![DistinctMSNNum]![MSM Number]) Then
Me.Command39.Enabled = False
Else
Me.Command39.Enabled = True
End If

End Sub

or, more consise,

Private Sub Form_Current()

Me.Command39.Enabled = Not IsNull(Forms![DistinctMSNNum]![MSM Number])

End Sub

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


lizza said:
I have a command button located in the form [IHS to Categorize] that I am
trying to disable when the form [DistinctMSNNum] returns null for the
record
[MSM Number]
If I try it with a record of the [IHS to Categorize] form it works but not
when i use a record in another table.. Any suggestions??

Thanks in advance

Private Sub Form_Current()

Dim test As String

test = "Forms![DistinctMSNNum]![MSM Number]"

'If IsNull([IHS Description]) Then


If IsNull(test) Then

Me.Command39.Enabled = False

Else

Me.Command39.Enabled = True

End If

End Sub
 
Back
Top