Submit and return the new unique ID to an IP field?

M

myost

I don't know if this is possible, but...

I'm using a button with a number of rules behind it to submit the form
data back to an access database. When the submit function is done I
want to then either return or pull from the database the new record's
unique ID that was created by the submission. Since I'll be doing
this all with the click of a button, I'm not too concerned about
multiple submissions causing the wrong ID to be returned.

I'm guessing this is possible but can't find any reference on how to
do it.

Thanks, Michael
 
A

Art

Sounds like you need to query the database but you will need a key to search
on that is unique to pull that record.

I know of no way to say just give me last row of table because what happens
if two forms submitted simultaneously?
 
G

gcadmindude

Art,

I'm using a series of checks within the code to prevent multiple
submissions. Basically, I set a boolean flag in the database upon opening
the form that prevents another user from opening the form. With this check
in place a second copy of the form can never be opened. The rules on open
check the flag, then automatically display a message to the user and closes
the form if the boolean flag is set. The custom submit button in the form
then clears that boolean flag so the form can be accessed by someone else.
There is no concern over multiple simultaneous submissions there will never
be 2 copies of the form open.

All I need is an example of the command or series of commands that will
return the last record. From there I can extract the unique ID.

I know there's a SQL command that returns the last row/record on a query but
don't know if there's a similar command for IP to do the same thing.

Michael
 
G

gcadmindude

As it happens I answered my own question.

I created the query in Access using
SELECT TOP 1 [Tablename].*
FROM [Tablename]
ORDER BY UNIQUEID DESC
WITH OWNERACCESS OPTION;

This query sorts the autonumbered unique ID in descending order putting the
last entry at the top, then returns the top row.

Then I created a secondary data connection to the query, and then added a
rule behind the button to query the secondary data connection.

Presto, last record returned when using an autonumbering scheme.

Enjoy gang...
 
J

Jay

You could use the following SQL Statement to return the maximum ID

SELECT MAX(UniqueID)
FROM


This is far more effiecent than select top....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top