Firstly, I was using the wrong SQL.
UPDATE Customer SET Customer.CUSBalance = [Customer]![CUSBalance]-[Forms]![Loan Payment]![Amount]
WHERE (((Customer.CUSID)=[Forms]![Loan Payment]![CUSID]));
Secondly I found that conditional formatting can not be applied to check boxes so I had to find a workaround and I found three.
work around 1
I locked the Post
check box and introduced a button which if Post = false
would run the query and make Post = True
MY FORM NOW
The Code I used on the post button [on click procedure]
Private Sub Command19_Click()
If Me.Post = False Then
DoCmd.SetWarnings False
DoCmd.OpenQuery "updateCustomerLoan"
DoCmd.SetWarnings True
Me.Post = True
MsgBox ("Record has been Posted")
ElseIf Me.Post = True Then
MsgBox ("Record has already been posted")
End If
End Sub
Work around 2
I applied the following code on post_update()
where I wrote two queries one do query (update) and one undo query (update)
Private Sub Post_AfterUpdate()
If Me.Post = True Then
DoCmd.SetWarnings False
DoCmd.OpenQuery "payLoanONpost"
DoCmd.SetWarnings True
MsgBox ("The record has been posted")
ElseIf Me.Post = False Then
DoCmd.SetWarnings False
DoCmd.OpenQuery "unpayLoanONunpost"
DoCmd.SetWarnings True
MsgBox ("Record has been unposted")
End If
End Sub
Work around 3 (by far the best and does what I initially set out to do
Here I only used one update query
Private Sub Post_AfterUpdate()
If Me.Post = True Then
DoCmd.SetWarnings False
DoCmd.OpenQuery "payLoanONpost"
DoCmd.SetWarnings True
MsgBox ("The record has been posted")
ElseIf Me.Post = False Then
MsgBox ("The record cannot unposted")
Me.Post = True
End If
End Sub