Avatar of Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc
Flag 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???????


Regards
Chris
Microsoft Access

Avatar of undefined
Last Comment
Ryan Chong

8/22/2022 - Mon
Ryan Chong

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.
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc

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

Under form after update like below:

If (Me.txtbalance) <> 0 Then
Beep
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!!!!!!!!

Regards

Chris
Ryan Chong

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

can you try that?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc

ASKER
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!

Regards

Chris
ASKER CERTIFIED SOLUTION
Gustav Brock

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc

ASKER
Thank you
Gustav Brock

You are welcome!

/gustav
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Dale Fye

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"
        me.subform1.form.textbox.setfocus
    end if

End Sub

Open in new window

Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc

ASKER
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

Chris
Ryan Chong

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?
http://support.experts-exchange.com/customer/portal/articles/2876519-how-do-i-report-content-to-site-advisers-and-moderators-
Your help has saved me hundreds of hours of internet surfing.
fblack61