473,588 Members | 2,478 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...contr ol source=[entry Subform].[Form]![Text12]
2.credit...cont rol source=[entry Subform].[Form]![Text14]
3.balance...con trol 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 948
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
2611
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 me 2 records with rec_id's of 14260 and 14261
5
1518
by: MLH | last post by:
Anyone remember how to determine a particular record's record number (Access 2.0 table question)?
15
11246
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 (for both the Mainform and Subform). No problem there. However, when I click on the navigation control of the subform to move to the next record in the subform, the AllowAdditions and AllowEdits changes to TRUE. Not good. I set...
1
2164
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 ADODB.Connection Dim ServerName As String Dim DatabaseName As String Dim TableName As String Dim UserID As String
9
24647
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 linked tables, which each link to separate SQL databases using separate ODBC connections. I have a form that has a view of table1 and a set of buttons for manipulating the data in database1.
1
2160
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 subform, which is based on a query, from the main form's coding. Thanks
2
1711
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 timely inputs and saved in a different table. but now i want to save the deleted record with extra coulms and delete it i mean removing from display. Any one help me.
1
3146
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 called OrderID. It is linked to a (sub)table called Parts (primary key: PartID: autonumber) and this one is linked to a (sub sub) table called SubParts (primary key: SubPartID: autonumber). The idea is that a Order can be filed for multiple parts and...
0
2106
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 every record like 1,2,3,...45,etc. It is not the case that every record will get increamented no. It may some record can be stored with same value like 35 some like 17 and so on. and records are retrieved based on this no. means in ascending...
3
7761
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 occurred to me. If a user starts typing a new record and decides they don't want a new record, is it possible to delete the record before it is saved? If so, then I could just replace my Undo button with a Delete button that will work as both my Undo...
0
7860
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8222
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8354
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8223
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5726
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3847
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3883
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1195
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.