Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying/Hiding labels

Status
Not open for further replies.

midiman69

Technical User
Apr 27, 2005
34
GB
I have a label on a main form which I wish to display if a sub form field= zero

I am using this
Private Sub Form_Current()
If Forms!frmprojectstabbed![qrybomsubform].Form![Currcosttotal] = 0 Then
Me.warning.Visible = True
ElseIf Forms!frmprojectstabbed![qrybomsubform].Form![Currcosttotal] > 0 Then
Me.warning.Visible = False
End If
End Sub

When I view the fisrt record with zero cost the label displays, when I move to the next with zero value it is hiden.

What am I doing wrong???

Dave
 
Try:
Me.warning.Visible = (Forms!frmprojectstabbed![qrybomsubform].Form![Currcosttotal] = 0)

I think that EsleIf ... should simply be Else, because there are only two possibilities. However, the idea above is shorter.
 
Thanks Remo,

I tried that and still have the same problem - the label is only visible on the first record with zero value??

Dave
 
Is it a proper zero or a null? Try:
Nz(Forms!frmprojectstabbed![qrybomsubform].Form![Currcosttotal],0) = 0
 
Hi Remou,

It is a proper zero, tried the Nz function as well - still the same - Ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh!!
 
Does this work?
Code:
Private Sub Form_Current()
    Me.warning.Visible = False
    If Forms!frmprojectstabbed![qrybomsubform].Form![Currcosttotal] = 0 Then Me.warning.Visible = True
End Sub

TMTOWDI - it's not just for Perl any more
 

use debug.print to inspect the code - use it so grab the values as it runs (I usually timestamp them too) and see if that helps. Also use the pause funtions to inspect the state of things as the code runs:

debug.print "Value: " & Me.Validate()
Me.ContactsBindingSource.EndEdit()
Me.ContactsTableAdapter.Update(Me.TestDB3DataSet.Contacts)
debug.print "Visible: " & Me.warning.Visible
 
I think you do it in the wrong event.
You may try the subform Current event procedure:
Private Sub Form_Current()
Forms!frmprojectstabbed!warning.Visible = (Me!Currcosttotal = 0)
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PHV - see what you been about using the sub form current event - tried your code - keep getting a type mismatch error??

Dave
 
And this ?
Forms!frmprojectstabbed!warning.Visible = (Nz(Me!Currcosttotal, 0) = 0)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks again PHV - I now get and invalid use of .(Dot) or ! or invalid Parenthesis message

Bugger!

Dave
 
Use the expression builder to discover the REAL names of your controls ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PHV

Thanks again - I checked the "REAL" names - they are all correct now get Method Nz of Object_' Aplication error.

Think I'll give up now!!

Cheers

Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top