
Q: Obtaining SQL Server Default Values While Adding Records in MS Access
Hi,
I'm trying to get around this slight complication here.
When adding records in MS Access to attached SQL Server tables, I want
to be able to pull the value of the primary key field, usually an
incremental unique index.
Now, I know when I add via DAO, it only sends the query over to SQL
server when you do an update.
ex:
rsWork = ODBCOpenDatabase("tbUsers")
rsWork.AddNew
rsWork.strUserName = UserName
rsWork.Update
so I'm pretty sure DAO won't be too helpful in this case, say I want
to obtain the value of the field
rsWork.lngUID
to get the User ID of the user I am adding. Since the query hasn't
been sent over to the back-end yet, that field (the PK field) is not
yet assigned a value.
Now, assuming the UserName is NOT a unique index, what is the easiest
way to get the value of the User ID AFTER I have added the record?
Or, more generally, when adding a record that does not contain unique
data, how do I obtain the correct PK index value after I have added a
record?
Now, I know a TimeStamp is pretty good for this, but I can't seem to
get TimeStamps to work properly in queries, since they are not ASCII
fields.
Any suggestions?
----
Adam P. Japhet
dtw Marketing Research Group, Inc.