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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

code not working

Status
Not open for further replies.

pfunk

Technical User
May 7, 2007
37
GB
i am having trouble with this code. even thought the payment due date has not arrived it still promts users to change.

Private Sub Notes_Click()
If Trim(Me![Status Codes]) = "PROMISE" Or Trim(Me![Payment_Due_Date]) <= Date Then
MsgBox "Your Debtor has Broken thier promise and you did not follow up on it therefore please code your status codes to Broken Promise ASAP."
Me![Status Codes].SetFocus
End If
End Sub
 
Maybe you want
Code:
Private Sub Notes_Click()
If Trim(Me![Status Codes]) = "PROMISE" [b][red]AND[/red] [/b] _
   Trim(Me![Payment_Due_Date]) <= Date() Then
   MsgBox "Your Debtor has Broken th[red]ei[/red]r promise and you did not follow up on it." & vbCrLf & _
          "Please code your status codes to Broken Promise ASAP."
   Me![Status Codes].SetFocus
End If
End Sub

With [red]OR[/red] it will prompt when Me![Status Codes]) = "PROMISE", regardless of the value of Payment_Due_Date.
 
Golom no dice now its not even prompting the msg box.
 
Have you confirmed by stepping through the code that the conditions are actually being met? i.e. that [Status Codes] = "PROMISE" AND [Payment_Due_Date] <= Date()



 
i have test a couple records back dating the promise [Payment_Due_Date] <= Date() for ie. testing purposes.
 
Try
Code:
If Trim$(Me![Status Codes]) = "PROMISE" And _
   [red]CDate([/red]Trim$(Me![Payment_Due_Date])[red])[/red] <= Date Then
It is possible that using "Trim" is attempting a string to date comparison. Force the conversion to date with the above code.
 
How are ya pfunk . . .

A simulation proves [blue]Golom's[/blue] last post is correct. [blue]Trim[/blue] is [purple]coercing[/purple] a string value! . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
thanks worked like a charm. what is CDate?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top