A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Value is Negative Code Problem!



 
 
Thread Tools Display Modes
  #1  
Old November 8th, 2004, 06:05 PM
Dave Elliott
external usenet poster
 
Posts: n/a
Default Value is Negative Code Problem!

Text377 is a computed value from another sub-form textbox.
If Text377 is a negative, i.e. Less Than Zero
Then Label30 should be visible
This code is on the current event of main form, it does not work.

If (Text377) = 0 Then
Label30.Visible = False
Else
Label30.Visible = (Text377) 0
End If


  #2  
Old November 8th, 2004, 07:28 PM
Dirk Goldgar
external usenet poster
 
Posts: n/a
Default

"Dave Elliott" wrote in message
. com
Text377 is a computed value from another sub-form textbox.
If Text377 is a negative, i.e. Less Than Zero
Then Label30 should be visible
This code is on the current event of main form, it does not work.

If (Text377) = 0 Then
Label30.Visible = False
Else
Label30.Visible = (Text377) 0
End If


Please try this and tell me if it works:

With Me!Text377
.Requery
Me!Label30.Visible = (.Value 0)
End With

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


  #3  
Old November 8th, 2004, 08:02 PM
Dave Elliott
external usenet poster
 
Posts: n/a
Default

I get a type mismatch error

"Dirk Goldgar" wrote in message
...
"Dave Elliott" wrote in message
. com
Text377 is a computed value from another sub-form textbox.
If Text377 is a negative, i.e. Less Than Zero
Then Label30 should be visible
This code is on the current event of main form, it does not work.

If (Text377) = 0 Then
Label30.Visible = False
Else
Label30.Visible = (Text377) 0
End If


Please try this and tell me if it works:

With Me!Text377
.Requery
Me!Label30.Visible = (.Value 0)
End With

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)




  #4  
Old November 8th, 2004, 08:48 PM
Dave Elliott
external usenet poster
 
Posts: n/a
Default

OK, here is my dilemna, I have a generic form I am using to test this with
no record source.
The TextBoxes have no control source other than the one I use to subtract
one amount from another to.
Everything works fine via this form, but when I try to use it on my main
form in th real db, it does not work. All the fields are the same as the
mock db except they do have a record source.
Here is the code I am using for the mock DB
More Details. The main form is named Timecards and the sub-form is named
TimeCardPaymentSub
The main form has the Text377 on it which gets it's computed data from the
sub-form Form Footer Text Box named Balance.
The main form also has the Label30 on it.
The Text Box Balance has it's control source set to the sub-form
TimeCardPaymentSub with this calculation.
=IIf(IsNull([SumPayment]),[OrderAmtA],[OrderAmtA]-[SumPayment])
Hope this explains better, I am lost...

If IsNull([Text377]) Then ' This is on the current event of the main
form.
Label30.Visible = False
Else
Label30.Visible = ([Text377] 0)
End If


If IsNull([Text377]) Then , This is on the sub-form after update
event.
Label30.Visible = False
Else
Label30.Visible = ([Text377] 0)
End If
"Dirk Goldgar" wrote in message
...
"Dave Elliott" wrote in message
. com
Text377 is a computed value from another sub-form textbox.
If Text377 is a negative, i.e. Less Than Zero
Then Label30 should be visible
This code is on the current event of main form, it does not work.

If (Text377) = 0 Then
Label30.Visible = False
Else
Label30.Visible = (Text377) 0
End If


Please try this and tell me if it works:

With Me!Text377
.Requery
Me!Label30.Visible = (.Value 0)
End With

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)




  #5  
Old November 8th, 2004, 10:48 PM
Dirk Goldgar
external usenet poster
 
Posts: n/a
Default

"Dave Elliott" wrote in message
om
OK, here is my dilemna, I have a generic form I am using to test this
with no record source.
The TextBoxes have no control source other than the one I use to
subtract one amount from another to.
Everything works fine via this form, but when I try to use it on my
main form in th real db, it does not work. All the fields are the
same as the mock db except they do have a record source.
Here is the code I am using for the mock DB
More Details. The main form is named Timecards and the sub-form is
named TimeCardPaymentSub
The main form has the Text377 on it which gets it's computed data
from the sub-form Form Footer Text Box named Balance.
The main form also has the Label30 on it.
The Text Box Balance has it's control source set to the sub-form
TimeCardPaymentSub with this calculation.
=IIf(IsNull([SumPayment]),[OrderAmtA],[OrderAmtA]-[SumPayment])
Hope this explains better, I am lost...

If IsNull([Text377]) Then ' This is on the current event of the
main form.
Label30.Visible = False
Else
Label30.Visible = ([Text377] 0)
End If


If IsNull([Text377]) Then , This is on the sub-form after
update event.
Label30.Visible = False
Else
Label30.Visible = ([Text377] 0)
End If
"Dirk Goldgar" wrote in message
...
"Dave Elliott" wrote in message
. com
Text377 is a computed value from another sub-form textbox.
If Text377 is a negative, i.e. Less Than Zero
Then Label30 should be visible
This code is on the current event of main form, it does not work.

If (Text377) = 0 Then
Label30.Visible = False
Else
Label30.Visible = (Text377) 0
End If


Please try this and tell me if it works:

With Me!Text377
.Requery
Me!Label30.Visible = (.Value 0)
End With


Okay, let's see what we can do with this information.

Create the following procedure in the General section of the main form's
module. Note that the subroutine is declared as Public:

'---- start of function code ----
Public Sub SetLabelVisibility()

With Me!Text377

' The following statement may not be necessary.
' After everything is working, take it out to see.
.Requery

If IsError(.Value) Then
Me!Label30.Visible = False
Else
Me!Label30.Visible = (Nz(.Value, 0) 0)
End If

End With

End Sub
'---- start of function code ----

Now we need to call this function in every event that might cause the
value of Text377 to change. As far as I can see, these are (a) the
Current event of the main form, (b) the AfterUpdate event of the
subform, and (c) the AfterDelConfirm event of the subform. I may have
missed something, since I don't have your form in front of me. So you
need the following event procedures.

'---- event procedure for main form's Current event ----
Private Sub Form_Current()

SetLabelVisibility

End Sub
'---- end event procedure for main form' Current event ----


'---- event procedure for subform's AfterUpdate event ----
Private Sub Form_AfterUpdate()

Me.Parent.SetLabelVisibility

End Sub
'---- end event procedure for subform's AfterUpdate event ----


'---- event procedure for subform's AfterDelConfirm event ----
Private Sub Form_AfterUpdate()

Me.Parent.SetLabelVisibility

End Sub
'---- end event procedure for subform's AfterDelConfirm event ----

Now, I haven't tested this but something along these lines ought to
work -- at least, I think it should if the Balance text box on the
subform doesn't contain #ERROR.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


  #6  
Old November 9th, 2004, 01:43 PM
Dave Elliott
external usenet poster
 
Posts: n/a
Default

Funny, If I use 0 for criteria, the Label30 shows up even though it is a
negative number, but if I use
0 it does not show up???
This has something with it being a negative number, dont know how to
resolve!

"Dirk Goldgar" wrote in message
...
"Dave Elliott" wrote in message
om
OK, here is my dilemna, I have a generic form I am using to test this
with no record source.
The TextBoxes have no control source other than the one I use to
subtract one amount from another to.
Everything works fine via this form, but when I try to use it on my
main form in th real db, it does not work. All the fields are the
same as the mock db except they do have a record source.
Here is the code I am using for the mock DB
More Details. The main form is named Timecards and the sub-form is
named TimeCardPaymentSub
The main form has the Text377 on it which gets it's computed data
from the sub-form Form Footer Text Box named Balance.
The main form also has the Label30 on it.
The Text Box Balance has it's control source set to the sub-form
TimeCardPaymentSub with this calculation.
=IIf(IsNull([SumPayment]),[OrderAmtA],[OrderAmtA]-[SumPayment])
Hope this explains better, I am lost...

If IsNull([Text377]) Then ' This is on the current event of the
main form.
Label30.Visible = False
Else
Label30.Visible = ([Text377] 0)
End If


If IsNull([Text377]) Then , This is on the sub-form after
update event.
Label30.Visible = False
Else
Label30.Visible = ([Text377] 0)
End If
"Dirk Goldgar" wrote in message
...
"Dave Elliott" wrote in message
. com
Text377 is a computed value from another sub-form textbox.
If Text377 is a negative, i.e. Less Than Zero
Then Label30 should be visible
This code is on the current event of main form, it does not work.

If (Text377) = 0 Then
Label30.Visible = False
Else
Label30.Visible = (Text377) 0
End If

Please try this and tell me if it works:

With Me!Text377
.Requery
Me!Label30.Visible = (.Value 0)
End With


Okay, let's see what we can do with this information.

Create the following procedure in the General section of the main form's
module. Note that the subroutine is declared as Public:

'---- start of function code ----
Public Sub SetLabelVisibility()

With Me!Text377

' The following statement may not be necessary.
' After everything is working, take it out to see.
.Requery

If IsError(.Value) Then
Me!Label30.Visible = False
Else
Me!Label30.Visible = (Nz(.Value, 0) 0)
End If

End With

End Sub
'---- start of function code ----

Now we need to call this function in every event that might cause the
value of Text377 to change. As far as I can see, these are (a) the
Current event of the main form, (b) the AfterUpdate event of the
subform, and (c) the AfterDelConfirm event of the subform. I may have
missed something, since I don't have your form in front of me. So you
need the following event procedures.

'---- event procedure for main form's Current event ----
Private Sub Form_Current()

SetLabelVisibility

End Sub
'---- end event procedure for main form' Current event ----


'---- event procedure for subform's AfterUpdate event ----
Private Sub Form_AfterUpdate()

Me.Parent.SetLabelVisibility

End Sub
'---- end event procedure for subform's AfterUpdate event ----


'---- event procedure for subform's AfterDelConfirm event ----
Private Sub Form_AfterUpdate()

Me.Parent.SetLabelVisibility

End Sub
'---- end event procedure for subform's AfterDelConfirm event ----

Now, I haven't tested this but something along these lines ought to
work -- at least, I think it should if the Balance text box on the
subform doesn't contain #ERROR.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)




  #7  
Old November 9th, 2004, 03:31 PM
Brendan Reynolds
external usenet poster
 
Posts: n/a
Default

Is it possible that the value is being treated as text? In a textual
comparison, "-1" "0" = True. What if you wrapped Val() around the value to
make sure it is treated as a number? Something like YourControl.Visible =
(Val(NZ(YourField, 0)) 0)

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.


"Dave Elliott" wrote in message
. com...
Funny, If I use 0 for criteria, the Label30 shows up even though it is a
negative number, but if I use
0 it does not show up???
This has something with it being a negative number, dont know how to
resolve!

"Dirk Goldgar" wrote in message
...
"Dave Elliott" wrote in message
om
OK, here is my dilemna, I have a generic form I am using to test this
with no record source.
The TextBoxes have no control source other than the one I use to
subtract one amount from another to.
Everything works fine via this form, but when I try to use it on my
main form in th real db, it does not work. All the fields are the
same as the mock db except they do have a record source.
Here is the code I am using for the mock DB
More Details. The main form is named Timecards and the sub-form is
named TimeCardPaymentSub
The main form has the Text377 on it which gets it's computed data
from the sub-form Form Footer Text Box named Balance.
The main form also has the Label30 on it.
The Text Box Balance has it's control source set to the sub-form
TimeCardPaymentSub with this calculation.
=IIf(IsNull([SumPayment]),[OrderAmtA],[OrderAmtA]-[SumPayment])
Hope this explains better, I am lost...

If IsNull([Text377]) Then ' This is on the current event of the
main form.
Label30.Visible = False
Else
Label30.Visible = ([Text377] 0)
End If


If IsNull([Text377]) Then , This is on the sub-form after
update event.
Label30.Visible = False
Else
Label30.Visible = ([Text377] 0)
End If
"Dirk Goldgar" wrote in message
...
"Dave Elliott" wrote in message
. com
Text377 is a computed value from another sub-form textbox.
If Text377 is a negative, i.e. Less Than Zero
Then Label30 should be visible
This code is on the current event of main form, it does not work.

If (Text377) = 0 Then
Label30.Visible = False
Else
Label30.Visible = (Text377) 0
End If

Please try this and tell me if it works:

With Me!Text377
.Requery
Me!Label30.Visible = (.Value 0)
End With


Okay, let's see what we can do with this information.

Create the following procedure in the General section of the main form's
module. Note that the subroutine is declared as Public:

'---- start of function code ----
Public Sub SetLabelVisibility()

With Me!Text377

' The following statement may not be necessary.
' After everything is working, take it out to see.
.Requery

If IsError(.Value) Then
Me!Label30.Visible = False
Else
Me!Label30.Visible = (Nz(.Value, 0) 0)
End If

End With

End Sub
'---- start of function code ----

Now we need to call this function in every event that might cause the
value of Text377 to change. As far as I can see, these are (a) the
Current event of the main form, (b) the AfterUpdate event of the
subform, and (c) the AfterDelConfirm event of the subform. I may have
missed something, since I don't have your form in front of me. So you
need the following event procedures.

'---- event procedure for main form's Current event ----
Private Sub Form_Current()

SetLabelVisibility

End Sub
'---- end event procedure for main form' Current event ----


'---- event procedure for subform's AfterUpdate event ----
Private Sub Form_AfterUpdate()

Me.Parent.SetLabelVisibility

End Sub
'---- end event procedure for subform's AfterUpdate event ----


'---- event procedure for subform's AfterDelConfirm event ----
Private Sub Form_AfterUpdate()

Me.Parent.SetLabelVisibility

End Sub
'---- end event procedure for subform's AfterDelConfirm event ----

Now, I haven't tested this but something along these lines ought to
work -- at least, I think it should if the Balance text box on the
subform doesn't contain #ERROR.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)






  #8  
Old November 9th, 2004, 04:11 PM
Dave Elliott
external usenet poster
 
Posts: n/a
Default

Tried that, it did not work. If I use rather than it works, else it does
not work.
Thanks,
If (Val(Nz(Text377, 0)) 0) Then
Label30.Visible = True
Else
Label30.Visible = False
End If

"Brendan Reynolds" brenreyn at indigo dot ie wrote in message
...
Is it possible that the value is being treated as text? In a textual
comparison, "-1" "0" = True. What if you wrapped Val() around the value
to make sure it is treated as a number? Something like YourControl.Visible
= (Val(NZ(YourField, 0)) 0)

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.


"Dave Elliott" wrote in message
. com...
Funny, If I use 0 for criteria, the Label30 shows up even though it is a
negative number, but if I use
0 it does not show up???
This has something with it being a negative number, dont know how to
resolve!

"Dirk Goldgar" wrote in message
...
"Dave Elliott" wrote in message
om
OK, here is my dilemna, I have a generic form I am using to test this
with no record source.
The TextBoxes have no control source other than the one I use to
subtract one amount from another to.
Everything works fine via this form, but when I try to use it on my
main form in th real db, it does not work. All the fields are the
same as the mock db except they do have a record source.
Here is the code I am using for the mock DB
More Details. The main form is named Timecards and the sub-form is
named TimeCardPaymentSub
The main form has the Text377 on it which gets it's computed data
from the sub-form Form Footer Text Box named Balance.
The main form also has the Label30 on it.
The Text Box Balance has it's control source set to the sub-form
TimeCardPaymentSub with this calculation.
=IIf(IsNull([SumPayment]),[OrderAmtA],[OrderAmtA]-[SumPayment])
Hope this explains better, I am lost...

If IsNull([Text377]) Then ' This is on the current event of the
main form.
Label30.Visible = False
Else
Label30.Visible = ([Text377] 0)
End If


If IsNull([Text377]) Then , This is on the sub-form after
update event.
Label30.Visible = False
Else
Label30.Visible = ([Text377] 0)
End If
"Dirk Goldgar" wrote in message
...
"Dave Elliott" wrote in message
. com
Text377 is a computed value from another sub-form textbox.
If Text377 is a negative, i.e. Less Than Zero
Then Label30 should be visible
This code is on the current event of main form, it does not work.

If (Text377) = 0 Then
Label30.Visible = False
Else
Label30.Visible = (Text377) 0
End If

Please try this and tell me if it works:

With Me!Text377
.Requery
Me!Label30.Visible = (.Value 0)
End With

Okay, let's see what we can do with this information.

Create the following procedure in the General section of the main form's
module. Note that the subroutine is declared as Public:

'---- start of function code ----
Public Sub SetLabelVisibility()

With Me!Text377

' The following statement may not be necessary.
' After everything is working, take it out to see.
.Requery

If IsError(.Value) Then
Me!Label30.Visible = False
Else
Me!Label30.Visible = (Nz(.Value, 0) 0)
End If

End With

End Sub
'---- start of function code ----

Now we need to call this function in every event that might cause the
value of Text377 to change. As far as I can see, these are (a) the
Current event of the main form, (b) the AfterUpdate event of the
subform, and (c) the AfterDelConfirm event of the subform. I may have
missed something, since I don't have your form in front of me. So you
need the following event procedures.

'---- event procedure for main form's Current event ----
Private Sub Form_Current()

SetLabelVisibility

End Sub
'---- end event procedure for main form' Current event ----


'---- event procedure for subform's AfterUpdate event ----
Private Sub Form_AfterUpdate()

Me.Parent.SetLabelVisibility

End Sub
'---- end event procedure for subform's AfterUpdate event ----


'---- event procedure for subform's AfterDelConfirm event ----
Private Sub Form_AfterUpdate()

Me.Parent.SetLabelVisibility

End Sub
'---- end event procedure for subform's AfterDelConfirm event ----

Now, I haven't tested this but something along these lines ought to
work -- at least, I think it should if the Balance text box on the
subform doesn't contain #ERROR.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)








  #9  
Old November 9th, 2004, 04:55 PM
Dirk Goldgar
external usenet poster
 
Posts: n/a
Default

"Dave Elliott" wrote in message
. com
Tried that, it did not work. If I use rather than it works, else
it does not work.
Thanks,
If (Val(Nz(Text377, 0)) 0) Then
Label30.Visible = True
Else
Label30.Visible = False
End If


Dave, you keep posting code that is not the code that I suggested, so I
don't know whether my suggestion didn't work or not.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


  #10  
Old November 9th, 2004, 05:11 PM
Brendan Reynolds
external usenet poster
 
Posts: n/a
Default

I can't reproduce this. I created a table with two fields, one long integer,
one text. I created a form with a text box and a label, and added the
following code to the AfterUpdate event procedure of the text box ...

Private Sub txtTest_AfterUpdate()

Me!lblTest.Visible = (Val(Nz(Me!txtTest, 0)) 0)

End Sub

I tested first with the text box bound to the long integer field, and then
with the text box bound to the text field. If I enter -1 or 0, the label is
hidden, if I enter 1, the label is shown, as expected. Next, I changed the
operator from the greater than to the less than operator ...

Private Sub txtTest_AfterUpdate()

Me!lblTest.Visible = (Val(Nz(Me!txtTest, 0)) 0)

End Sub

Now if I enter -1 the label is shown, if I enter 0 or 1, the label is
hidden, as expected. Again, tested with the control bound first to the long
integer field, then the text field, with the same result.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.


"Dave Elliott" wrote in message
. com...
Tried that, it did not work. If I use rather than it works, else it
does not work.
Thanks,
If (Val(Nz(Text377, 0)) 0) Then
Label30.Visible = True
Else
Label30.Visible = False
End If

"Brendan Reynolds" brenreyn at indigo dot ie wrote in message
...
Is it possible that the value is being treated as text? In a textual
comparison, "-1" "0" = True. What if you wrapped Val() around the value
to make sure it is treated as a number? Something like
YourControl.Visible = (Val(NZ(YourField, 0)) 0)

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible
for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.


"Dave Elliott" wrote in message
. com...
Funny, If I use 0 for criteria, the Label30 shows up even though it is
a negative number, but if I use
0 it does not show up???
This has something with it being a negative number, dont know how to
resolve!

"Dirk Goldgar" wrote in message
...
"Dave Elliott" wrote in message
om
OK, here is my dilemna, I have a generic form I am using to test this
with no record source.
The TextBoxes have no control source other than the one I use to
subtract one amount from another to.
Everything works fine via this form, but when I try to use it on my
main form in th real db, it does not work. All the fields are the
same as the mock db except they do have a record source.
Here is the code I am using for the mock DB
More Details. The main form is named Timecards and the sub-form is
named TimeCardPaymentSub
The main form has the Text377 on it which gets it's computed data
from the sub-form Form Footer Text Box named Balance.
The main form also has the Label30 on it.
The Text Box Balance has it's control source set to the sub-form
TimeCardPaymentSub with this calculation.
=IIf(IsNull([SumPayment]),[OrderAmtA],[OrderAmtA]-[SumPayment])
Hope this explains better, I am lost...

If IsNull([Text377]) Then ' This is on the current event of the
main form.
Label30.Visible = False
Else
Label30.Visible = ([Text377] 0)
End If


If IsNull([Text377]) Then , This is on the sub-form after
update event.
Label30.Visible = False
Else
Label30.Visible = ([Text377] 0)
End If
"Dirk Goldgar" wrote in message
...
"Dave Elliott" wrote in message
. com
Text377 is a computed value from another sub-form textbox.
If Text377 is a negative, i.e. Less Than Zero
Then Label30 should be visible
This code is on the current event of main form, it does not work.

If (Text377) = 0 Then
Label30.Visible = False
Else
Label30.Visible = (Text377) 0
End If

Please try this and tell me if it works:

With Me!Text377
.Requery
Me!Label30.Visible = (.Value 0)
End With

Okay, let's see what we can do with this information.

Create the following procedure in the General section of the main
form's
module. Note that the subroutine is declared as Public:

'---- start of function code ----
Public Sub SetLabelVisibility()

With Me!Text377

' The following statement may not be necessary.
' After everything is working, take it out to see.
.Requery

If IsError(.Value) Then
Me!Label30.Visible = False
Else
Me!Label30.Visible = (Nz(.Value, 0) 0)
End If

End With

End Sub
'---- start of function code ----

Now we need to call this function in every event that might cause the
value of Text377 to change. As far as I can see, these are (a) the
Current event of the main form, (b) the AfterUpdate event of the
subform, and (c) the AfterDelConfirm event of the subform. I may have
missed something, since I don't have your form in front of me. So you
need the following event procedures.

'---- event procedure for main form's Current event ----
Private Sub Form_Current()

SetLabelVisibility

End Sub
'---- end event procedure for main form' Current event ----


'---- event procedure for subform's AfterUpdate event ----
Private Sub Form_AfterUpdate()

Me.Parent.SetLabelVisibility

End Sub
'---- end event procedure for subform's AfterUpdate event ----


'---- event procedure for subform's AfterDelConfirm event ----
Private Sub Form_AfterUpdate()

Me.Parent.SetLabelVisibility

End Sub
'---- end event procedure for subform's AfterDelConfirm event ----

Now, I haven't tested this but something along these lines ought to
work -- at least, I think it should if the Balance text box on the
subform doesn't contain #ERROR.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)










 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Export to RTF very slow when code is present in Access report. [email protected] Setting Up & Running Reports 11 September 14th, 2004 08:17 PM
Conversion of excel vba code to access vba filnigeria General Discussion 5 July 15th, 2004 02:23 AM
Chip code problem - conditional formatting colors GetStrippedValue Barney Fife Worksheet Functions 0 June 16th, 2004 10:23 PM


All times are GMT +1. The time now is 03:25 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.