Hide CommandButton If txtbox.value = 0

O

ohlrichar

I am trying to hide a command button if the value of a text box = 0.

The text box recieves values from afterupdate events from optiongroups,
nothing is ever manually entered into this text box.

What I currently have is :

Private Sub AuditTotalDisc_Dirty(Cancel As Integer)
If Me.AuditTotalDisc.Value = "0" Then
Me.Command1496.Visible = False
Else
Me.Command1496.Visible = True
End If
End Sub


I have been able to get this to work if I manually enter the data into the
text box. I have not been able to get it if the number is generated through
the optiongroups. I also tried changing the event to Afterupdate and Change
neither of those worked.


Any ideas of where I went wrong?

Thanks
 
O

ohlrichar

Ok. I got it to work by correcting the VBA a bit. However, I am still
having a small problem.

I am unable to get the button to appear while I am on the record. It will
only appear after I change records and go back to it. Any ideas on how to
fix that?

Any and all help is greatly appreciated.

Private Sub AuditTotalDisc_AfterUpdate()
If Me.AuditTotalDisc = 0 Then
Me.Command1496.Visible = False
Else
Me.Command1496.Visible = True
End If
End Sub
 
J

John W. Vinson

I am unable to get the button to appear while I am on the record. It will
only appear after I change records and go back to it. Any ideas on how to
fix that?

Put the same code in the form's Current event.
 

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