Save Button with conditions
Posted on 2012-08-24
My problems is as follows: (using A97 and A03)
I have a form for inputting data and a Save button created using the wizard which saves the data. However I have added additional code to the the Event procedure which I want carriedout prior to the save:
Private Sub Command181_Click()
Dim total As Integer
total = ([share1] + [share2] + [share3] + [share4])
If Text118 = "" Then
MsgBox ("Please enter Reference")
If total < 99.5 Or total > 100 Then
MsgBox ("Share total is not equal to 100")
ElseIf total >= 99.5 And total <= 100 Then
MsgBox ("Share total has been accepted as 100")
On Error GoTo Err_Command181_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Everything functions ok. However the problem that i have is that even though the conditions work, the data is saved irrespective.
I would like that when the condition fails i.e. the share total is not equal to a hundred that the data is not saved until the condition is met i.e. that the total share equals a hundred.
Grateful for assistance or ideas or similar code or a similar sample I could try.