473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Update an Access field on change of another field - Access 2016 Windows platform

I am working with a Form and have a currency field ([Amt_Tendered]) and a check box field ([Treasurer]) from a table source. I would like the check box field to change to False (0) if the value in the currency field should change. I tried the OnChange, AfterUpdate, OnExit properties of the Amt_Tendered field with =Iif([Treasurer]=-1,0,0) but it does not change the True value to False or zero as I would like it to. Any suggestions?
Aug 3 '18 #1

✓ answered by zmbd

Hopefully you've renamed your controls from their default names.

Open the form in design view
Show the properties for your text field
in the after_update event

Expand|Select|Wrap|Line Numbers
  1. Private Sub Ctrl_Txt_Amt_Tendered]_AfterUpdate()
  2.   Me![Treasurer]  = False
  3.   Me.Refresh
  4. End Sub
This is the most simplistic version.

7 9887
twinnyfo
3,653 Expert Mod 2GB
Kime1266,

It would be helpful to see your entire procedure, so we could troubleshoot.

However, based upon what you've described, you only wan tthe Treasurer check box to change if the Amt_Tendered changes? What I mean by this is, if someone updates that field with the same, unchanged ammount, then the check should not change.

One way to do this is add a hidden text box to the form called txtAmt_TenderedCheck. In the form's OnCurrent Event:

Expand|Select|Wrap|Line Numbers
  1. Me.txtAmt_TenderedCheck = Me.Amt_Tendered
In the AfterUpdate Event of the Amt_Tendered text Box (I hope you have it named something else, like txtAmt_TenderedCheck--if not, you should!):

Expand|Select|Wrap|Line Numbers
  1. Me.chkTreasurer = (Me.txtAmt_Tendered = Me.txtAmt_TenderedCheck)
Again, this assumes a proper naming convention for the Treasurer check box.

Hope this hepps!
Aug 3 '18 #2
zmbd
5,501 Expert Mod 4TB
Hopefully you've renamed your controls from their default names.

Open the form in design view
Show the properties for your text field
in the after_update event

Expand|Select|Wrap|Line Numbers
  1. Private Sub Ctrl_Txt_Amt_Tendered]_AfterUpdate()
  2.   Me![Treasurer]  = False
  3.   Me.Refresh
  4. End Sub
This is the most simplistic version.
Aug 3 '18 #3
zmbd
5,501 Expert Mod 4TB
Looks like twinnyfo and cross-posted - :-)

However, based upon what you've described, you only wan the Treasurer check box to change if the Amt_Tendered changes? What I mean by this is, if someone updates that field with the same, unchanged amount, then the check should not change.
no need for a hidden text box :-)

Try this instead:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Ctrl_Txt_Amt_Tendered_AfterUpdate()
  2.   'Only refreshing the snapshot of the record. No need to do a full requery for same record changes.
  3.   Me.Refresh
  4. End Sub
  5.  
  6. Private Sub Ctrl_Txt_Amt_Tendered_BeforeUpdate(Cancel As Integer)
  7.   If Not Me.Ctrl_Txt_Amt_Tendered.OldValue Like Me.Ctrl_Txt_Amt_Tendered.Value Then
  8.     Me![Treasurer] = False
  9.   End If
  10. End Sub
Kime1266,
Pay very close attention here - I am referring to controls in one instance and to the form's record set in the second

Me![Treasurer] is referencing the form's data source
Me.Ctrl_Txt_Amnt is referencing the control
This is important - and is why many of us strongly advise renaming the controls from the horrible MS-Default names.
Aug 3 '18 #4
Thank you for your response. I guess I am not following the most current standard naming conventions.
Aug 4 '18 #5
This worked like a charm. It did exactly what I was trying to do. I guess I was trying to bypass writing an event procedure by trying to use an expression or macro which obviously was not the correct solution. Thank you so much for expertise and for muddling through my poor explanation.
Aug 4 '18 #6
twinnyfo
3,653 Expert Mod 2GB
Hey Z,

I’m gonna have to look into the .OldValue property. I keep forgetting that it exists, but I think I could use it in some of my applications.

Thanks for the reminder.
Aug 4 '18 #7
zmbd
5,501 Expert Mod 4TB
NB: the .OldValue property only works with bound controls
-
For unbound controls I'll often use the .Tag property storing it from the On_Enter event
-
Aug 4 '18 #8

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

Similar topics

0
by: Jason Joines | last post by:
I have a table with an email field that contains values of the form uid@domain. I need to populate a new field called uid with just the uid part of the email address. Is there any way of using...
1
by: Tony Johnson | last post by:
I want to update a particular field in a form for only a certain set of records. The certain set of records is named Financed. I need to update those Financed records with a financed number that...
2
by: Rooksarii | last post by:
Hello folks, Let me first apologize for any impropper terminology I may use as I am presently trying to broaden my Office knowledge by diving into Access head on. My specific problem is this....
9
by: geronimo_me | last post by:
Hi, I am atempting to compare part of a field with the whole of another field in access. Is this possible? Basically I have 2 tables with the following info: Table1 Field1 = MR.
0
by: cemal | last post by:
hi guys. I have two table ; categories and products categories table; catid (int) catname, and products table has catid(int), catname I want to update products.catid=catgory.catid where...
2
by: Andrius B. | last post by:
Hi. I am writing an app, whitch has to access a database, located on another computer (Intranet). Let's say, the computer where the app is to be installed, is "Computer1". The computer with the...
0
by: g_k_harrison | last post by:
Hi. I've been at this database all day so this may come out muddled. I have MS Access 2000 in which I have a form with a several fields in which dollar amounts are entered. It's like this:
2
by: zufie | last post by:
How would I transfer the values from my WorkPhone field to my CellPhone field within the same table IBCCP Referral? Thanks!, John
1
by: Blessy Benigna | last post by:
i have created a postgresql 9.1 database on a windows 7 OS. now i want to access it via another windows 7 OS pc using pgadminIII.On the client pc i have also installed pgadminIII as a client...
8
by: mburch2000 | last post by:
I have an Excel file with two tabs: Source & Target. Using VBA (Macro), I am attempting to take data in Source and place in Target. The fields are normally manipulating in some form, so not a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...

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.