473,406 Members | 2,336 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,406 software developers and data experts.

Validate value in combobox based on before/after update

294 256MB
I have a combobox on a form where users can select number of payouts. The choices are 3, 5 and 10.

I am trying to implement a validation rule that checks to see if the user tries to change the number of payouts to a number less than what was in the combobox prior to their change. If so, do not allow the change to be saved.

Example:

The current number of payouts is: 10
*User tries to change to 5*
Validation Text: You've made an invalid election.
*System does not allow them to save that change*

I know we need to capture the value in the combobox before update, and also use it in the after update, to compare each selection, yet I'm not sure how to store the value of the before update selection.

Anyone have any ideas? Thanks
Jan 27 '14 #1

✓ answered by Rabbit

You can do it all in the before update, check the old value against the value that it will update to. Both are available to you in that event. The OldValue property will hold the original value.

4 4288
Rabbit
12,516 Expert Mod 8TB
You can do it all in the before update, check the old value against the value that it will update to. Both are available to you in that event. The OldValue property will hold the original value.
Jan 27 '14 #2
mcupito
294 256MB
Great - Thanks, Rabbit!

Although what you said has helped me. I am still left with one question.

If I do:
Expand|Select|Wrap|Line Numbers
  1. If Me.PayoutCbx.OldValue > Me.PayoutCbx.Value Then
  2.     MsgBox ("Number Of Payouts cannot be decreased.")
  3. End If
How do I prevent the user's entry to over-ride the oldvalue? I tried .SetFocus and Me.PayoutCbx = Me.PayoutCbx.OldValue, and neither worked.
Jan 27 '14 #3
zmbd
5,501 Expert Mod 4TB
Expand|Select|Wrap|Line Numbers
  1. Cancel = true
  2. Me!ControlNameHere.Undo
(note, the undo is valid for bound controls)

Please see the section for the before update even in the MS Developer's materials: Form.BeforeUpdate Event (Access) Office 2010 There are a few more code snipits for you to look at in the reference too (^_^)
Jan 28 '14 #4
mcupito
294 256MB
Great - Thanks, zmbd! Works beautifully.
Jan 28 '14 #5

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

Similar topics

6
by: Dugo | last post by:
I'm trying to use a "keypad" form (with command buttons for numbers 0 thru 9) I developed to allow users to first click a textbox on one form, then click a number on the keypad and have the value...
1
by: Dave | last post by:
I'm having problems with certain fields that I force an update (Me.dirty=false) in the After Update Event I lose focus of the field where the user was or where he clicked help Is there a way...
5
by: keri | last post by:
Hi, I am struggling to learn access and VBA whilst creating a db, progress is slow! So far I have managed to run cascading combo boxes on a form by using a sub in the after update procedure of...
1
by: HenHouse | last post by:
Hi all; I think I've asked this question before but it looks like I'm going to need a deeper understanding of the problem rather than just a quick fix... I have three tables represented by three...
4
by: injanib via AccessMonster.com | last post by:
I have a combo box called "Recipient" who's row source is a table called "Main" with three columns. The three columns are "Name", "Floor", "Location". Following the combo box are two fields called...
2
by: eihabisaac | last post by:
Hi everyone I'm using VS2005 C# with MySQL to do a windows application i'm also using Devart for MySQL i was able to populate a combobox from the database but i really want to populate...
4
by: phill86 | last post by:
Hi, i have a form that runs a query in a recordset on the after update method if i copy and paste one record at a time the query picks up the records in the underlying table but if i paste...
5
by: katlego | last post by:
Hi Can sum1 plz help i want to display student results on the studentSubform based on the selection i make in the combobox so far this is what ive got. Query called students whereby the names of...
4
TheSmileyCoder
by: TheSmileyCoder | last post by:
Im trying to have some fun with the imagecombo control, but so far its alot more frustration then it is fun. From what I have understood I can't tie the imagecombobox directly to a field in a...
7
by: sheela gupta | last post by:
I want to populate the combobox based on the selected item in the first combobox The following code is written in vb.net 2008 Public Class Form1 Sub fillcombo() strsql = "select *...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.