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  

Automatic data field



 
 
Thread Tools Display Modes
  #1  
Old March 22nd, 2008, 02:09 PM posted to microsoft.public.access.tablesdbdesign
Steve Chaffin[_2_]
external usenet poster
 
Posts: 1
Default Automatic data field

I want to create a field that is based upon 2 other fields. In the first
field is a text characted. In the second field there is also a text
character. I want to create a third field that compares the two fields and if
they are identical produces a true if they are not identical produces a
false. Any ideas?
  #2  
Old March 22nd, 2008, 02:46 PM posted to microsoft.public.access.tablesdbdesign
Michael Gramelspacher
external usenet poster
 
Posts: 482
Default Automatic data field

On Sat, 22 Mar 2008 07:09:00 -0700, Steve Chaffin
wrote:

I want to create a field that is based upon 2 other fields. In the first
field is a text characted. In the second field there is also a text
character. I want to create a third field that compares the two fields and if
they are identical produces a true if they are not identical produces a
false. Any ideas?


CREATE TABLE MyTable
(
column1 VARCHAR (20),
column2 VARCHAR (20)
);

INSERT INTO MyTable VALUES ('Gram','Gram');
INSERT INTO MyTable VALUES ('Steinle','Stein');

SELECT MyTable.column1,
MyTable.column2,
IIF([column1] = [column2],-1,0) AS Comparable
FROM MyTable;

column1 column2 Comparable
Gram Gram -1
Steinle Stein 0

SELECT MyTable.column1,
MyTable.column2,
IIF([column1] LIKE "*" & [column2] & "*",-1,0) AS Comparable
FROM MyTable;

column1 column2 Comparable
Gram Gram -1
Steinle Stein -1

  #3  
Old March 22nd, 2008, 05:08 PM posted to microsoft.public.access.tablesdbdesign
Evi
external usenet poster
 
Posts: 898
Default Automatic data field

May I suggest that you do this in a query rather than a table, then, if you
have to change Field1 or Field2 the answer will still be correct.
Put your table fields into a query
In a blank column in the Design View of your query type

Compr:[Field1]=[Field2]
This will give you a -1 if it is true and a 0 if it is false

If you want to the -1 to be a one then have

-([Field1]=[Field2])

Evi
"Steve Chaffin" wrote in message
...
I want to create a field that is based upon 2 other fields. In the first
field is a text characted. In the second field there is also a text
character. I want to create a third field that compares the two fields and

if
they are identical produces a true if they are not identical produces a
false. Any ideas?



 




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 11:26 AM.


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