Solved

Validating one field based on another in the same record

Posted on 2011-03-15
3
202 Views
Last Modified: 2012-08-14
My database tracks barrel racing events.  There is an event table with one record for each event and a class table that contains a record for each class in each event.  I have a form, Add/Update Events, which contains event information on the main form and a datasheet view of class records related to the event currently displayed. In the class table I have many fields which contain information relevant to the class but for purposes of this question, the class table has these fields: EventID, ClassType (text), IncentiveOnly (yes/no), RollFromClass (text).  The field, RollFromClass, should be left null unless IncentiveOnly is set to yes.  In that case, RollFromClass should be assigned a value. That value should only be one of the values previously assigned to ClassType for a class in the current event.

There are 2 data validation issues I am not sure how to handle.  The first is to ensure that RollFromClass is initialized when IncentiveOnly equals yes.  The second is how to ensure that RollFromClass is initialized correctly, i.e., to one of the values previously entered as ClassType for this event.

Should any of this validation be defined at the table level?  Should I handle it all in the form?  I tried writing code to execute "on exit" from the RollFromClass field but I'm not sure I know how to reference specific rows in the datasheet view correctly.  What do you suggest?
0
Comment
Question by:ProgrammingGrandma
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 35138667
You will have to use vba code in a data entry form for this.

But I don't really understand what you mean by..
"That value should only be one of the values previously assigned to ClassType for a class in the current event."

This sounds like you have to be referring to other records in the table, which is a bit of a pain in itself, but I don't quite get what you would do with the first record  ( and the logic which follows is that that the second record must be the same as the first, the third must also be the same and so on)

0
 

Accepted Solution

by:
ProgrammingGrandma earned 0 total points
ID: 35139239
OK.  I will focus on VBA code in the form.  The form looks something like this:

Event: Winter Race
Date:   Dec 4, 2010

Class Type       Race Format...      Incentive Only?       Roll From Class

Open Poles       3D                          N
Youth Poles       3D                          Y                              Open Poles
Senior Poles      3D                          Y                              Open Poles
Open Barrels     4D                          N
Youth Barrels     4D                          Y                              Open Barrels

All this data is for the same event.  If Incentive Only? is no, there is no value allowed in Roll From Class.  If Incentive Only? is yes, Roll From Class must have a value and it must be one of the classes already defined for this event and therefore, displayed on this form.  (An incentive only class is one where the contestants don't actually make another run, we just roll their times from the open event to the incentive class they entered.)

In my VBA code, how do I address fields in the subform?  If I use me.[Incentive Only], will VBA assume I am referring to the row which currently contains the cursor or do I need to address the row more specifically?  I am asking because using me.[Incentive Only] in my code is getting inconsistent results.

Secondly, if I do want the user to enter a value in Roll From Class, can I dynamically create a combo box which includes the values currently on the form in the column Class Type?
0
 

Author Closing Comment

by:ProgrammingGrandma
ID: 35225387
My issue is not resolved.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question