Trying to disable a command button in visual basic

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
 
D

Douglas J. Steele

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
 
L

lizza

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
 

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

Top