473,513 Members | 2,339 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

balance record before move to new record

2 New Member
hello
I'm useing access 2007
I have 3 unbound textbox in form
1.debit...control source=[entry Subform].[Form]![Text12]
2.credit...control source=[entry Subform].[Form]![Text14]
3.balance...control source
this 3 unbound textbox take data form unbound textbox in subform as Text12:sum[debit] .. Text14:sum[credit]
balance:=[Text12]-[Text14]
i make new unbound textbox for balance in form
the control source is. =[entry Subform].[Form]![Text16]
he give me balance zero when debit = credit
but my question is how can use validation rule or before update or any simple way to check if this balance not equal to be zero before move to new record in form.
how to get msg balance not equal.
Feb 27 '17 #1
2 946
PhilOfWalton
1,430 Recognized Expert Top Contributor
First of all, the ControlSource shoull hav an Nz function in case the data is blank

Expand|Select|Wrap|Line Numbers
  1. 1.debit...control source=Nz([entry Subform].[Form]![Text12])
  2.  
Secondly, you will make life much easier for yourself if you give the text boxes meaningful names.

Thirdly, I strongly advise against having spaces in form names or field names so we are now down to

Expand|Select|Wrap|Line Numbers
  1. 1.debit...control source=EntrySubform.Form!TxtDebit
  2.  
Now to get to your question (at long last)

You need to check the balance before updating your form, so do your calculation for the balance as you indicate and then on the Before Update, try the following code

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2.  
  3.    If Balance <> 0 then
  4.         Msgbox "The balance is: " & Format(Balance, "Currency")
  5.         Cancel = True
  6.    End If
  7.  
Phil
Feb 28 '17 #2
daoud
2 New Member
PhilofWalton thank you so much to help me.
I'll take your advices to me as a teacher, I'm not expert in ''MS Access'' , my knowledge come by self learning ,I'm accountant.
I'll try your code.

Thanks again.
Mar 1 '17 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2607
by: Andrew | last post by:
Hi All, Have come across something weird and am after some help. Say i run this query where rec_id is a column of table arlhrl, select * from arlhrl where rec_id >= 14260 This returns to...
5
1513
by: MLH | last post by:
Anyone remember how to determine a particular record's record number (Access 2.0 table question)?
15
11231
by: Susan Bricker | last post by:
Greetings. I have a Mainform with a subform. The Mainform has single record format and subform has continuous form format. When the Mainform opens, I force allowadditions and allowedits to FALSE...
1
2154
by: sal21 sal21 | last post by:
I use this code to update a sql database from excel to sql... Now i would want to arange this code to export an Access table into sql databse... Sub ADOExcelToSQLServer() Dim Cn As...
9
24615
by: Joshua.Buss | last post by:
I am trying to move a record from one linked table to another within access, but I'm a complete beginner to VBA and don't know exactly where to begin. I have an access file that has the two...
1
2155
by: grgimpy | last post by:
This is MS Access: Is it possible to move the RecordSelectors in a subform from the main form's coding? I want to use a RecordSelectors.MoveLast type code that will move to the last record in a...
2
1708
subashini Thiyagarajan
by: subashini Thiyagarajan | last post by:
hi, i want to delete a record.hope it is very easy.but same time i want to move the deleted record in to new table for report generation in future. i succeeded in deleting the record along with...
1
3137
by: bemadragon | last post by:
Hello, I have been struggling with this for a while. I am working on a rather simple database for calculation purposes in Access 2003. I have a table called Order that has a primary key field...
0
2102
by: mukeshrasm | last post by:
Hi I wanted to move record up or down or top or bottom if user selects up or down or top or bottom from select box. records are coming from database. while saving record I am assigning no. to...
3
7737
Seth Schrock
by: Seth Schrock | last post by:
I've got a way for the user to delete the record. The user just didn't know it. I might end up putting a Delete button next to the Undo button so that they can find it easier. An idea just...
0
7267
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7553
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7542
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4754
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3247
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3235
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1609
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.