Equivalent to a SQL Trigger in Access ???

  • Thread starter Thread starter Dwayne Conyers
  • Start date Start date
D

Dwayne Conyers

We would like to implement something like a trigger... when either of two
columns are updated, a third column is updated with the concatenated value
of the other two columns.

So, if column "A" is edited by the user as "Teddy" and column "B" is edited
by the user as "Roosevelt" column "C" will be updated to contain (with an
added space) "Teddy Roosevelt."

In SQL, we can create a trigger on the table to do that. How would this be
implemented in Access?

Thanks in advance!
 
Dwayne,

Sounds like you are wanting to store the results of a calculation
(concatenation) in your table, when you don't really need to. Just do the
concatenation in the form/query/report when you run it.

--
Kevin Hill
President
3NF Consulting

www.3nf-inc.com/NewsGroups.htm
 
I actually need to use this in a combo box, and would rather have a "clean"
string than have two fields appear in the drop-down control. The combo box
will update a hidden field containing an integer (the integer of the
selected item). That is why we need the concatenation.
 
In addition to the other responses:
Access .mdb files do NOT support triggers.
(Access .adp files do since they are linked to SQL Server.)

In an .mdb you have to froce theuser to *always* use your UI and *never* let
them run directly against a Table or Query. The Form events can simulate
triggers.
 
SELECT MyTable.id, [fname]+" "+[lname] AS FullName FROM MyTable;

Ampersands are a little bit safer than plusses here, as a NULL in one of
the fields will propagate to the whole string.

NULL + "Something" = NULL

NULL & "Something" = "Something"

B Wishes


Tim F
 
Excellent point...I just slapped it together for demo purposes :-)

--
Kevin Hill
President
3NF Consulting

www.3nf-inc.com/NewsGroups.htm

Tim Ferguson said:
SELECT MyTable.id, [fname]+" "+[lname] AS FullName FROM MyTable;

Ampersands are a little bit safer than plusses here, as a NULL in one of
the fields will propagate to the whole string.

NULL + "Something" = NULL

NULL & "Something" = "Something"

B Wishes


Tim F
 
Back
Top