Populate Field2 From Field1

G

Guest

Trying to get field2 (Synonyms) to automatically populate with data from
field1 (ChemName). Both fields are from the same table (Chemicals) and are on
the same form (ChemicalLocations). Tried this code on the ChemName field
after update but it doesn't work:

If Not IsNull(Me!ChemName) Then
Me!ChemName = Me!Synonyms
Else
Me!Synonyms = Null
End If

Any ideas? Thanks.
 
D

DavidG

Synonyms FROM Chemname ?
Also Zero field length case...

if len(me!ChemName & "") > 0 then
Me!Synonyms = Me!ChemName
else
Me!Synonyms = null
end if

HTH

DavidG

----- Original Message -----
From: "MBoozer" <[email protected]>
Newsgroups: microsoft.public.access.formscoding
Sent: Sunday, November 27, 2005 7:10 AM
Subject: Populate Field2 From Field1
 
J

John Vinson

Trying to get field2 (Synonyms) to automatically populate with data from
field1 (ChemName). Both fields are from the same table (Chemicals) and are on
the same form (ChemicalLocations). Tried this code on the ChemName field
after update but it doesn't work:

If Not IsNull(Me!ChemName) Then
Me!ChemName = Me!Synonyms
Else
Me!Synonyms = Null
End If

Any ideas? Thanks.

Sounds like you have the first replacement backwards. If you're
updating the ChemName field it's very unlikely to be NULL; and in any
case, you'ld be overwriting it with the value of Synonyms, rather than
vice versa.

If you want to "get Synonyms to automatically populate with data from
ChemName" you would need to use

Me!Synonyms = Me!ChemName

HOWEVER - why would you want to store the ChemName redundantly in the
Synonyms field? Wouldn't a given chemical have *multiple* synonyms,
which should therefore be in a "many" side related table? What's your
table structure?

John W. Vinson[MVP]
 
G

Guest

Thanks guys. Works great! I needed to do this. Yes John, the synonyms data
will be different. However, the synonyms will be different but they will
"also" include the original name of the chemical as well and there is no
sense in entering the chemical name twice. The only alternative that I know
of is to concatenante the two fields which is a little much. Thanks.
 
J

John Vinson

Thanks guys. Works great! I needed to do this. Yes John, the synonyms data
will be different. However, the synonyms will be different but they will
"also" include the original name of the chemical as well and there is no
sense in entering the chemical name twice. The only alternative that I know
of is to concatenante the two fields which is a little much. Thanks.

You *are* storing the synonyms in a related table, and using a Subform
to enter them, I hope? I fear not since there should be no mainform
control for the synonym...

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top