If Then

  • Thread starter Thread starter Jerry Stoner
  • Start date Start date
J

Jerry Stoner

Guest
If txtBal = 0 Then
chkPaid.Value = -1

Doesn't work. The problem is txtBal is a calculated control. If I change it to a noncalculated control the above works fine. What is the correct way to ascertain the value and act on the result?
 
Try:

If Me.txtBal.value = 0 then
chkPaid.Value = -1
else
'whatever...
Endif
 
Thanks but that didn't do it. Tried that and about a dozen other things. To reiterate the problem seems to lie in the fact that txtBal is a calculated control =([txtTotalDue]-[txtAmountPaid]) whose source is also a calculated control.
txtTotalDue comes from =([txtSubtotal]+[txtFreight]) and txtAmountPaid comes from =Nz([tblSales].[Form]![tblPayments Subform].[Form]![txtPaymentSum],0).
txtSubtotal is also calculated as is txtPaymentSum.So I have the sums of 6 calculations to derive txtBal.Any ideas anyone?
 
Ok got somewhere, before I couldnt get chkPaid to check at all. This however checks chkPaid all the time. Any ideas??

If Nz(txtBal, 0) = 0 Then
chkpaid.Value = -1
End If

If IIf(txtBal, [txtTotalDue] - [txtAmountPaid], 0) = 0 Then
chkpaid.Value = -1
End If
Does the same thing. Any Help?
 
Try If Me.txtTotalDue - Me.txtAmountPaid =0 Then
Me.chkPaid=True
Else
Me.chkPaid=False
End If
 
Rich, been down that road but tried it again anyway and no love. chkPaid.Value stays 0 allways. Really dont get why.
Thanks and any other suggestions?
 
Let me ask this... when refering to a control in a sub is there any difference in the way you refer to a calculated control as opposed to a control that is not calculated?
 
I've just tried
If Me.txtBal =0 Then
Me.chk1=True
Else
Me.chk1=False
End If
on a report with no problems on a calculated control. Where are you using the code?
 
Here and it doesnt work.Really dont understand this.

Private Sub Form_Current()
'Feb28 2002 Jerry Stoner
'Exit if new record.
'Make chkPaid -1 if txtBal = 0.
'If order PastDue enable Check Box and turn forecolor Red.
If Me.NewRecord = True Then
Exit Sub
End If
If Me.txtBal = 0 Then
Me.chkPaid = True
Else
Me.chkPaid = False
End If


If txtDateDue < Date And chkpaid.Value = 0 Then

chkPastDue.Value = -1
txtDateDue.ForeColor = 255


Else

chkPastDue.Value = 0
txtDateDue.ForeColor = 0
End If

Exit Sub

End Sub

[This message has been edited by Jerry Stoner (edited 03-01-2002).]
 
What type of form continuous? If that's the case and you've got A2k then you might be able to use conditional formatting. Or set the control source of the check box to =If([txtBal]=0,True,False)

[This message has been edited by Rich (edited 03-02-2002).]

[This message has been edited by Rich (edited 03-02-2002).]
 
Hi Rich, its a single form.Setting control source didnt work either.
 
OK send it I'll take a look
smile.gif
 
I assume you are the same Rich who took a look at a report problem I had? What Im asking is is your e-mail address richiet@xxx.xxx
 
=IIf([txtBal]=0,True,False)
In the control source of the checkbox was Rich's correct answer. Thank you very much

[This message has been edited by Jerry Stoner (edited 03-03-2002).]
 

Users who are viewing this thread

Back
Top Bottom