Solved

Validating one field based on another in the same record

Posted on 2011-03-15
3
199 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
  • 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
access pop-up form 3 30
Access 2016 5 53
Dlookup MSACCESS 5 24
Field naming convntions - MS Access 6 12
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

816 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now