Q: Obtaining SQL Server Default Values While Adding Records in MS Access 
Author Message
 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.



Mon, 01 Nov 1999 03:00:00 GMT  
 Q: Obtaining SQL Server Default Values While Adding Records in MS Access

Please forgive me If I'm wrong, I do not have any experience with SQL
server.

Ok now that I've got the disclaimer in there, have your tried to do:
RsWork.MoveLast  'after the update this moves to the new record that was
just written.



Tue, 02 Nov 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Moving Oracle records to MS SQL Server using MS Access

2. Complicated Record Handling on MS Sql server and MS Accesses Databases

3. Acc97:Obtaining Auto Number field value after adding a record

4. Executing MS SQL Server 2000 stored procs via MS Access 2000

5. CA-Prog Analyst, MS SQL Server, Visual Basic and MS Access

6. Access to MS ACCES and MS SQL server

7. Change default value in SQL Server attachment

8. DataAdapter.Update and SQL Server Default Values

9. How to get default values into dataset from sql server table

10. getting default values from sql server table

11. getting default values for sql server table

12. Application Development: MS-Access, Visual Basic, SQL Server, SQL Anywhere

 

 
Powered by phpBB® Forum Software