If Not IsNull Code not working, Please Help!

D

Dave Elliott

This code is run on the current event of a sub-form
if Payment has a value and Balance equals zero then, etc...
nothing happens? Payment and Balance are in currency format.

If Not IsNull(Payment) And (Balance) = 0 Then
MsgBox "Print Customers Receipt Upon Completion of Payment(s)"
End If
 
D

Dave Elliott

Tried this also with no success!
If Not IsNull("Forms!TimeCardPaymentSub!Payment") And
("Forms!TimeCardPaymentSub!Balance") = 0 Then
MsgBox "Print Customers Receipt Upon Completion of Payment(s)"
End If
 
G

George Nicholson

1) Try it without the quotations around "Forms!....Field"
2) Be sure TimeCardPaymentSub is the name of the Control containing the
subform. This may be the same as the name of the subform, but the name of
the subform itself is immaterial, it's the name of the container control
that matters.

HTH,
 
D

Dirk Goldgar

Dave Elliott said:
This code is run on the current event of a sub-form
if Payment has a value and Balance equals zero then, etc...
nothing happens? Payment and Balance are in currency format.

If Not IsNull(Payment) And (Balance) = 0 Then
MsgBox "Print Customers Receipt Upon Completion of Payment(s)"
End If

Does this work?

If (IsNull(Payment) = False) And (Balance = 0) Then
 
D

Dave Elliott

Yes, but also needed to add 3rd criteria ; StartDte is a date field and
if it has a date in it then etc... with 3rd, does not work?

If (IsNull(Payment) = False) And (Balance = 0) And IsDate(StartDte) Then
MsgBox "Please Print Customers Receipt"
End If
 
D

Dirk Goldgar

Dave Elliott said:
Yes, but also needed to add 3rd criteria ; StartDte is a date
field and if it has a date in it then etc... with 3rd, does not work?

If (IsNull(Payment) = False) And (Balance = 0) And IsDate(StartDte)
Then MsgBox "Please Print Customers Receipt"
End If

I don't see why that wouldn't work. In what way doesn't it work?
 
D

Dave Elliott

Ok, this works for me, but how can I make it ask me if i want to print the
receipt ornot if so print?

DoCmd.OpenReport "InvoiceReport", acPreview, "",
"[TimeID]=[Forms]![TimeCards]![TimeID]"
If [Forms]![TimeCards]![BidDiscAmt] < DSum("Payment", "TPaymentSub",
"TimeID = [Forms]![TimeCards]!TimeID") Then
Reports!InvoiceReport!QuoteInvLabel.Caption = "Credit Invoice"
Else: Reports!InvoiceReport!QuoteInvLabel.Caption = "Invoice"
End If
 
D

Dave Elliott

I need for the Pay value if it is greater than zero to be true so formula
will work right, how can i change this?
right now the code only works if both Pay and Bal are zero
Bal is ok to be zero

If (IsNull(Pay) = False) And (Bal) = 0 Then
Label455.Visible = True
Else
Label455.Visible = False
End If
 
D

Dirk Goldgar

Dave Elliott said:
It does not make the message box appear!

Then I suggest you check what the current values of Payment, Balance,
and StartDte are when the code is executed. I don't think there's any
way that code can fail to display the message box if all the following
are true:

1. Payment is not Null
2. Balance is equal to 0
3. StartDte contains a date value

You might put a breakpoint on the If statement, do what it takes to
trigger the code, and when it stops at the breakpoint, examine the
values of those fields or variables.
 
D

Dirk Goldgar

Dave Elliott said:
Ok, this works for me, but how can I make it ask me if i want to
print the receipt ornot if so print?

DoCmd.OpenReport "InvoiceReport", acPreview, "",
"[TimeID]=[Forms]![TimeCards]![TimeID]"
If [Forms]![TimeCards]![BidDiscAmt] < DSum("Payment",
"TPaymentSub", "TimeID = [Forms]![TimeCards]!TimeID") Then
Reports!InvoiceReport!QuoteInvLabel.Caption = "Credit
Invoice" Else: Reports!InvoiceReport!QuoteInvLabel.Caption =
"Invoice" End If

I don't understand the context of the question. You'd need to explain
more about what you're trying to do.
 
D

Dirk Goldgar

Dave Elliott said:
I need for the Pay value if it is greater than zero to be true so
formula will work right, how can i change this?
right now the code only works if both Pay and Bal are zero
Bal is ok to be zero

If (IsNull(Pay) = False) And (Bal) = 0 Then
Label455.Visible = True
Else
Label455.Visible = False
End If

What you seem to be saying is not possible, given that code. The test
"If (IsNull(Pay) = False)" doesn't care whether Pay is 0, greater than
0, or less than 0 -- it only cares whether it's Null or not. If you
think it does, you are misinterpreting what is going on. On the other
hand, if you mean something else by "the code works", you need to
explain what "working" code would do that this code doesn't do.
 

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