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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a new year - and checking to see if its already there

Status
Not open for further replies.

Gerimc

Programmer
Jul 22, 2003
19
GB
I have a table called FinancialYearTbl which contains the fields FinYearPkFld, FinYearDescritpionFld and a RedundantFld. I also have a form called MaintainFinancialYearFrm Which shows the FinancialYearDescritpion field and a redundant check box. A user will use this form to add new financial years, edit them and delete or make the year redunant depending upon whether the year has been used or not.
When a user adds a new financial year i need the database to check the financial year table to see if that financial year description has been added before. if it has i want an error message to come up else i want the new year to be added. Any idea how i could do this ?
 
The default behaviour of Access is to reject the record if it is a duplicate (with a default message box) or insert it if it is new. Presumably you want something slightly slicker in some way?

 
My financial year description isn't my primary key so there is no validation on my form to stop me from having the same fiancial year string entered more than once. I am inputing my fin year in the following format 2001/02 the primary key is just an autonumber so the database is just letting me enter any format of number
 
If that is unique then put a unique index on it to prevent duplicates. However it seems that is actiually the primary key so just delete your autonumber field and declare the year field as the primary key.

Autonumbers are handy if you have a set of things eg general ledger entries that you want an identifier for. Where you already have one, especially a nice short one like 2xxx/yy, then using that is much better all round.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top