Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 27th, 2010, 12:11 PM
Authorized User
 
Join Date: Feb 2007
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default 1 : n Default value for the n

Hello,

I am working on 2 data entry forms.
The first form is to enter data to a table (the '1' table), the primary key is an autonumber field.
The second form that must open after a new row has been added tot the '1' table is used to add 1 or more rows to the 'n' table. I want to have the foreign key - field in the form to enter data to the 'n' table to have the default value of the primary key last assigned to the '1' table.
I have tried various ideas to set the default value but they resulted amongst others in #Name? errors.
Who can help setting the default value on the second form to the last assigned primary key number in the first table.

Many thanks in advance,

John
 
Old September 27th, 2010, 01:13 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi...

SELECT @@IDENTITY will result in returning the last autonumber used on your last insert query.
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old September 28th, 2010, 08:08 AM
Authorized User
 
Join Date: Feb 2007
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Gonzalo,

Thanks very much!

John





Similar Threads
Thread Thread Starter Forum Replies Last Post
Code for Chpt.2-Wrox File Share is missing Default.aspx and Default.aspx.vb bzoni BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 October 23rd, 2009 02:39 PM
drop down default value MunishBhatia ASP.NET 2.0 Professional 4 September 5th, 2007 10:31 AM
What does this("Default Name") mean? webworldman C# 0 July 28th, 2006 07:55 AM
default ambrosejp SharePoint Admin 2 April 20th, 2006 01:56 PM
Datagrid default value eddiema C# 1 May 21st, 2004 11:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.