Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2003
    Location
    Moorpark, CA
    Posts
    104

    Talking Unanswered: Question about Yes/No

    Hi All -

    I want to write the code so that when a date is entered in a field it compares it to a due date (i.e. 15th of every month) and a yes/no box is automatically checked if it is on time. Do you know if this is possible? Any suggestions?

    Also, If I write this code and then later on I want to click the box yes even though it doesn't fall in the appropriate range (an override) is that okay? It won't uncheck the box next time the code is run? I would assume the code would be based on when the date was entered and that date won't ever change once it is inputted.

    Does that make sense to anyone? It makes sense to me =)

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    Sure it's possible

    Because your clients payments are record specific (each payment will be a seperate record), your CheckBox will be (or should be) as well in relation to the very same record. You should have no need to worry about code rerunning to change things unless you re-enter a new 'Payment Made' date within a record that allready contained a supplied date for that record. Therefore...the placement of code would be the key here (I would think).

    Put this code into the BeforeUpdate event for your 'Payment Made' entry field on your Form:
    Code:
    If Me.myFormsPaymentMadeDateField < = Me.myFormsDueDateField then
       Me.myFormsYesNoCheckBoxField.Value = True
    Else
       Me.myFormsYesNoCheckBoxField.Value = False
    End If
    Now.....In the MouseDown event for your CheckBox, place this code:
    Code:
    If (Me.myFormsPaymentMadeDateField > Me.myFormsDueDateField) And Me.myFormsYesNoCheckBoxField.Value = False Then
       Dim DaysOverdue As Integer
       DaysOverdue = DateDiff("d", Me.myFormsDueDateField, Me.myFormsPaymentMadeDateField)
       If MsgBox("It is noticed that the payment supplied is overdue by " & DaysOverdue & " days but " & _
    			 "you still want to indicate that the payment was made on or before the Due Date. " & _
    			 "Are you sure you want to do this?", vbExclamation + vbYesNo, _
    			 vbNewLine & vbNewLine & "Override - Payment Before Due") = vbYes Then
    	  Me.myFormsYesNoCheckBoxField.Value = True
       Else
    	  Me.myFormsYesNoCheckBoxField.Value = False
    	  Button = 0: Me.myFormsPaymentMadeDateField.SetFocus
       End If
    End If
    That should do it for you. Of course, be sure to place the proper control names into the code rather that the ficticious ones I've used here.

    Hope this helps.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •