A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Validation Rule



 
 
Thread Tools Display Modes
  #1  
Old May 18th, 2004, 09:56 PM
Tom
external usenet poster
 
Posts: n/a
Default Validation Rule

I am wondering if someone knows how to create a validation rule in a table that would throw an error message in a form.

Here's what I have in a table:

Field1
- Data type = Number
- Indexed = "Yes (Duplicates OK)"

Field2
- Data type = Text
- Indexed = "No"


Validation Rule Requirements:
- The value of Field2 must be unique within the range of same value range of Field1


Examples of Allowed Records:

Field1 Field2
====== ======
1 A
1 B
1 C
2 A
2 B
3 B


Examples of Not Allowed Records:

Field1 Field2
====== ======
1 A
1 B
1 B
2 A
2 B
3 B


Here, the values of the 2nd record and 3rd record (Field1 = 1, Field2 = B) are identical. Therefore, when entering the 3rd record, I want to throw an error message in a form that indicates
that Field2 value of "B" already exists.

Is that possible?


P.S. I don't want to use autonumbers for this table.


--
Thanks,
Tom


  #2  
Old May 18th, 2004, 10:12 PM
Rick B
external usenet poster
 
Posts: n/a
Default Validation Rule

You need to create a key for your table based on two fields. I believe you hold down the CTRL key while you click the fields, then click the "key" button at the top of your screen.

Rick B


"Tom" wrote in message ...
I am wondering if someone knows how to create a validation rule in a table that would throw an error message in a form.

Here's what I have in a table:

Field1
- Data type = Number
- Indexed = "Yes (Duplicates OK)"

Field2
- Data type = Text
- Indexed = "No"


Validation Rule Requirements:
- The value of Field2 must be unique within the range of same value range of Field1


Examples of Allowed Records:

Field1 Field2
====== ======
1 A
1 B
1 C
2 A
2 B
3 B


Examples of Not Allowed Records:

Field1 Field2
====== ======
1 A
1 B
1 B
2 A
2 B
3 B


Here, the values of the 2nd record and 3rd record (Field1 = 1, Field2 = B) are identical. Therefore, when entering the 3rd record, I want to throw an error message in a form that indicates
that Field2 value of "B" already exists.

Is that possible?


P.S. I don't want to use autonumbers for this table.


--
Thanks,
Tom


  #3  
Old May 18th, 2004, 10:15 PM
Rick B
external usenet poster
 
Posts: n/a
Default Validation Rule

After you do that, you can select "Indexes" from the "View" menu to see more options for your key.

See "help" for more details.

HTH

Rick B

"Tom" wrote in message ...
I am wondering if someone knows how to create a validation rule in a table that would throw an error message in a form.

Here's what I have in a table:

Field1
- Data type = Number
- Indexed = "Yes (Duplicates OK)"

Field2
- Data type = Text
- Indexed = "No"


Validation Rule Requirements:
- The value of Field2 must be unique within the range of same value range of Field1


Examples of Allowed Records:

Field1 Field2
====== ======
1 A
1 B
1 C
2 A
2 B
3 B


Examples of Not Allowed Records:

Field1 Field2
====== ======
1 A
1 B
1 B
2 A
2 B
3 B


Here, the values of the 2nd record and 3rd record (Field1 = 1, Field2 = B) are identical. Therefore, when entering the 3rd record, I want to throw an error message in a form that indicates
that Field2 value of "B" already exists.

Is that possible?


P.S. I don't want to use autonumbers for this table.


--
Thanks,
Tom


  #4  
Old May 18th, 2004, 10:27 PM
Tom
external usenet poster
 
Posts: n/a
Default Validation Rule

Rick:

Thanks!!! That works perfect!


Tom



"Rick B" wrote in message ...
You need to create a key for your table based on two fields. I believe you hold down the CTRL key while you click the fields, then click the "key" button at the top of your screen.

Rick B


"Tom" wrote in message ...
I am wondering if someone knows how to create a validation rule in a table that would throw an error message in a form.

Here's what I have in a table:

Field1
- Data type = Number
- Indexed = "Yes (Duplicates OK)"

Field2
- Data type = Text
- Indexed = "No"


Validation Rule Requirements:
- The value of Field2 must be unique within the range of same value range of Field1


Examples of Allowed Records:

Field1 Field2
====== ======
1 A
1 B
1 C
2 A
2 B
3 B


Examples of Not Allowed Records:

Field1 Field2
====== ======
1 A
1 B
1 B
2 A
2 B
3 B


Here, the values of the 2nd record and 3rd record (Field1 = 1, Field2 = B) are identical. Therefore, when entering the 3rd record, I want to throw an error message in a form that indicates
that Field2 value of "B" already exists.

Is that possible?


P.S. I don't want to use autonumbers for this table.


--
Thanks,
Tom


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:21 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.