[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

VBA - Determine last Inserted UID

Posted on 2006-11-06
7
Medium Priority
?
370 Views
Last Modified: 2008-03-10
Hi guys,

I wanted to know if it's possible to run an Insert statement on a table, and then determine what the UID (also the primary key) of that entry is?

Cheers guys!
0
Comment
Question by:Cyber-Drugs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 1200 total points
ID: 17882189
If it's an autonumber, Try this:

LastID = DMax("UID","YourTable")
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 800 total points
ID: 17882197
not accurate in multiple user

Dmax("UID","TableName")
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17882217
How multi user is your database gonna be

if u use a recordset to add (one I prefer to use if u have several fields to add) then once u do AddNew, u get the UID number (if its a autonumber)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 4

Author Comment

by:Cyber-Drugs
ID: 17882234
There will be one whole user of this amazingly big database (excuse the sarcasm :P )

So I can presume Dmax() will be safe?
0
 
LVL 61

Expert Comment

by:mbizup
ID: 17882262
Yes.  If you wanted to expand, you'd need to do something else.
0
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 1200 total points
ID: 17882299
For a multiuser database, Rocki's VBA suggestion would work, or this variation on the DMax, assuming you're tracking who creates the record:
Dmax("UID","TableName","CreatedBy = '" & currentUser & "'")
0
 
LVL 4

Author Comment

by:Cyber-Drugs
ID: 17882391
Cheers guys!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question