Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comparing DB Entries within a field and Validating them

Status
Not open for further replies.

usheikh

Programmer
May 16, 2005
25
GB
Hi,

This may be a little difficult to explain but here goes:

I have a table in access 97 with the field Account. An account name is usually written as 0000000_A, but it MAY also have a secondary account and is usually written with the same first series of digits but ends in B e.g. 0000000_B. Therefore, we could have an account 0023654_A and 0023654_B.

Now for each account name there is another field called Items which are chosen from a combo box on a form (item 1, item 2, item 3, item 4, item 5, item 6, item 7 and item 8). An account may have more than one item.

Now if account B exists then it MUST contain the same entries as account A but can also have additional items.
So we could have a situation where:

0023654_A
item 1
item 2
item 3
item 4

0023654_B
item 1
item 2
item 3
item 4
item 5
item 6

Now what I am trying to implement is that if the core items (these are those that are contained in both - which would be item 1, item 2, item 3 and item 4 in the above example) are changed in either accounts making them not equal then a warning message should come up stating so. IT IS IMPERATIVE THAT THE CORE ITEMS ARE PRESENT IN BOTH.

I have some experience in Access 97, but unsure of how to tackle this. Could somebody please guide me ???
Since all accounts are treated as seperate in the database even those with secondary accounts, I was unsure how to go about it. Basically do I need to relate accounts together ??? If so then how?? Or is there a simpler way? I was thinking about validation rules on table properties, but I guess that is only for validating text.

The table below is similar to what I'm working on but with thousands of accounts. Is there a way of comparing the same fields of a column? Could a rule not be put into place for the table so that:

Account Item
------------ ------
987654_A 1
987654_A 2
987654_A 3
987654_A 4
987654_A 5
987654_B 1
987654_B 2
987654_B 3
987654_B 4
888888_A 1
888888_A 2
888888_A 3
888888_A 4
888888_B 1
888888_B 2
888888_B 3
888888_B 4


Basically:
For each account in the table, if the account number ends in _A then find the same account number (first 6 digits) but ending with _B. If there isnt an account ending in _B then it doesnt matter, but if there is then ensure that _B contains all items in _A. If this is not the case then display a general warning "Invalid Items Error".


Can this be done???

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top