Quote:
Sub calculate_tot_per()
On Error GoTo Err_calculate_tot_per
Me!tot_per = CDec(Me!in_5_1 + Me!in_5_2 + Me!in_5_3 + Me!in_5_4 + Me!in_5_5 + Me!in_5_6 + Me!in_5_7 + Me!in_5_8 + Me!in_5_9)
Me!balance_per = 100 - Me!tot_per
Exit_calculate_tot_per:
Exit Sub
Err_calculate_tot_per:
MsgBox Err.Description
Resume Exit_calculate_tot_per
End Sub
We used a button for the user to close and save the record if the total was not 100% then an error message was displayed. From memory we used CDEC as the total at times was not 100 but 99.999 etc but the figures on the screen totalled 100.
Quote:
strmsg = "Select Yes to save your the changes and exit" & Space(20) & _
vbCrLf & " " & _
vbCrLf & "Select No to exit without saving the changes" & _
vbCrLf & " " & _
vbCrLf & "Select Cancel to return to the screen"
msg_title = "Save changes" & Space(20)
Response = MsgBox(strmsg, vbYesNoCancel + vbDefaultButton3 + vbExclamation, msg_title)
Select Case Response
Case vbYes
If Me!tot_per = 100 Then ' save the record
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.Close acForm, "form name"
Else
strmsg = "Percentages changed do not add up to 100%." & Space(20) & _
vbCrLf & "No changes made. " & _
vbCrLf & "You will have to start again. "
msg_title = "Save Modules changes" & Space(20)
Response = MsgBox(strmsg, vbYes + vbDefaultButton1 + vbExclamation, msg_title)
DoCmd.Close acForm, "form name"
End If
Case vbNo
DoCmd.Close acForm, "form name"
End Select
Hope this helps you