Private Sub AddRecord_Click()
Dim Account As String
Dim LastPaid As Date
Dim NewPaymentDate As Date
Dim Last_Bill_Due_Date As Date
Dim Bill_Due_Date As Date
If IsNull(txtBillName) Then
MsgBox "You have not selected an account.", vbOKCancel, " No Account Selected"
Exit Sub
End If
If IsNull(Me.[New Bill_Due_Date]) Then
MsgBox "You have not selected a New Bill Due Date. ", vbOKCancel, " No Bill Due Date"
Exit Sub
End If
DoCmd.SetWarnings False
Account = [lstBillName].[Column](0)
NewPaymentDate = Me.[New Bill_Due_Date]
LastPaid = Me.[LastPaid]
Last_Bill_Due_Date = Me.[Bill_Due_Date]
On Error GoTo Err_AddRecord_Click
'create a new record
DoCmd.RunSQL "INSERT INTO Bills (Bill_Name, Last_Paid, NextPaymentDate) VALUES ('" & Account & "', '" & Last_Bill_Due_Date & "', '" & NewPaymentDate & "')"
MsgBox "The new bill due date (" & NewPaymentDate & ") for " & "'" & Account & "'" & " has been entered. This screen reflects the new bill due date.", vbOKCancel, " New Bill Due Date Added"
Me.[New Bill_Due_Date] = ""
[COLOR="Red"]Me.Bill_Due_Date.ForeColor = 255
[/COLOR]
Requery
DoCmd.SetWarnings True
Exit_AddRecord_Click:
Exit Sub
Err_AddRecord_Click:
MsgBox Err.Description
Resume Exit_AddRecord_Click
End Sub