Control Visible Conditionally

D

David

I have a button that I want to be visible if a text box holds a value of less
than -1.
In the form's current event I have the following code but I keep getting an
error of "data mismatch"

Me.BadButton.Visible=Me.Balance<-1

The Balance field is a calculated field that shows the net transaction
amount and is formatted as currency. If a loss of over $1.00 is found, an
explanation must be entered on the form that will be opened by this button.
Any suggestions on how to fix this?
 
M

MikeT

I would try using the same calculation that the calculated field
uses in my Form_Current event, store the result in a variable, and
set the BadButton.Visible property based on the value of the
variable.

Max
 
D

David

Good idea... however, the calculated field makes it's calculations based on
serveral other calculations and lookups on the results of queries. That would
be quite a lengthy statement.

Is there any other way?
 
R

Ron Weiner

David

Try

Me.BadButton.Visible = nz(Me.Balance,0)<-1

I am thinking that you get the error when Me.Balance is Null. Due to the
propagation of Nulls Me.Balance<-1 will return Null whenever Me.Balance is
Null. And Null is not gonna be acceptable to BadButton's visible property
which will only accept True/False.

Ron W
 

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