Link to home
Create AccountLog in
Avatar of Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.ScFlag for Zambia

asked on

Validating controls

Validating controls

I have a control on the [parent form purchases] which sums the total value of goods received note from the tables (txtgrnValue). This control is used to net off with the purchases subform (txtgrandtotal), for simplicit purpose see below:

Txtgrnvalue – txtgrandtotal = 0 (txtbalance)

If the net of the above two controls is zero (txtbalance), then it is safe for the users to proceed to the next sub form which deals with double entries.

Now assuming the net of the two is not zero (txtbalance), I want to stop the users from proceeding to next sub form until the above control is balanced off to zero.
How do I do it????
Which event to use???????

Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

in the AfterUpdate event of txtbalance, try to check if its value is greater than zero, if yes, disable your "Next" button or so, else enable that option.
Avatar of Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc


Kindly demonstrate your answer properly, are saying it is supposed to

Under form after update like below:

If (Me.txtbalance) <> 0 Then
MsgBox " Please check the txtbalance control is out of balance"
Cancel = True
Exit Sub
End If
End Sub

I have tried it , it is not working!!!!!!!!


Under form after update
i was mentioned in the AfterUpdate event of txtbalance not form's AfterUpdate event.

can you try that?
A constant message keeps on popping up

What I want is a situation like after updating the sub form and immediately when attempting to leave the sub form to the next sub form then that message should pop up if the txtbalance control is not zero. Is there a way to do it in ms access!


Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
You are welcome!

The other thing I do with subforms with this type of functionality is use the subform controls Exit event, which has a Cancel argument.

You would open your main form in design view, click on the subform control and view the properties of the control.  Select the Exit property and then do something like:

Private Sub subForm1_Exit (Cancel as integer)

    Cancel = me.subform1.form.textbox <> 0
    if Cancel then
        msgbox "balance the values before proceeding"
    end if

End Sub

Open in new window

Thank you so much this is actually the best answer , but how I reopen this query to apportion the points to you as well???????????

Once again

Thank you so much

but how I reopen this query to apportion the points to you as well???????????
you can try click the "Report Question" option.

How do I report content to site advisers and moderators?