This topic is locked

check if record exists then action

4/18/2008 12:47:59 PM
ASPRunnerPro General questions
H
heets author

I have two access tables that both use the a field called "Name Id" as their key. When someone updates the one of these tables I would like to update a field called "last update date" on the other table.
I'm trying to use the check if specific record exists example but I'm stuck on the select statement -
strSQLExists = "select * from NAMES where [Name Id]=
If I hard code a Name Id value and edit that particular record everything works so the rest of my code is working but what goes after the = ? The table I am editing is called xrefactivy and the table I am trying to update is called NAMES.
Is the [Name Id] from the xrefactivity table still available if I put this code in "after record updated"?
Thanks for any help you can give me.
Bruce

Sergey Kornilov admin 4/21/2008

Bruce,
try the following:
strSQLExists = "select * from NAMES where [Name Id]=" & keys("Name ID")
I assume that 'Name ID' is a numeric field.

H
heets author 4/21/2008

Unfortunately, Name Id is not numeric. I inherited this database.

Does this change anything?

Sergey Kornilov admin 4/21/2008

In this case you need to wrap key column value by single quotes:
strSQLExists = "select * from NAMES where [Name Id]='" & keys("Name ID") & "'"