A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Split database



 
 
Thread Tools Display Modes
  #11  
Old November 24th, 2007, 04:55 AM posted to microsoft.public.access.tablesdbdesign
Tony Toews [MVP]
external usenet poster
 
Posts: 3,776
Default Split database

"Rick Brandt" wrote:

AutoNumber usage makes the use of "temp" or "work" tables very problematic.

You would first have to append the flight data to the real table omitting the
AutoNumber field so that the back end applies its own value. Then you would
have to retrieve that value so you can use it when you append the crew data.
Depending on how you do that and how many users might be simultaneously
appending records this can be very tricky.


I respectfully disagree. When using DAO the following works very
well to determine the last record just inserted.

RS.Move 0, RS.LastModified
lngTableListID = RS!stlid

If using SQL then it I vaguely recall something about some kind of @@
SQL command would work even in an Jet database but I don't recall any
details now.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
  #12  
Old November 24th, 2007, 05:08 PM posted to microsoft.public.access.tablesdbdesign
RoyVidar
external usenet poster
 
Posts: 417
Default Split database

Tony Toews [MVP] wrote:

If using SQL then it I vaguely recall something about some kind of @@
SQL command would work even in an Jet database but I don't recall any
details now.


Yes, with ADO, I think it could look something like the following

cn.Execute "INSERT INTO TheTable.....", , adCmdText + adExecuteNoRecords
Set rs = cn.Execute("SELECT @@Identity", , adCmdText)
Debug.Print rs.Fields(0).Value

cn being a valid ADO connection, @@Identity will return the last
Identity (Autonumber) inserted on this connection.
--
Roy-Vidar
  #13  
Old November 24th, 2007, 06:08 PM posted to microsoft.public.access.tablesdbdesign
Tony Toews [MVP]
external usenet poster
 
Posts: 3,776
Default Split database

RoyVidar wrote:

If using SQL then it I vaguely recall something about some kind of @@
SQL command would work even in an Jet database but I don't recall any
details now.


Yes, with ADO, I think it could look something like the following

cn.Execute "INSERT INTO TheTable.....", , adCmdText + adExecuteNoRecords
Set rs = cn.Execute("SELECT @@Identity", , adCmdText)
Debug.Print rs.Fields(0).Value

cn being a valid ADO connection, @@Identity will return the last
Identity (Autonumber) inserted on this connection.


Yup, that looks familiar.

Thanks, Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
  #14  
Old November 24th, 2007, 06:10 PM posted to microsoft.public.access.tablesdbdesign
Tony Toews [MVP]
external usenet poster
 
Posts: 3,776
Default Split database

RoyVidar wrote:

Set rs = cn.Execute("SELECT @@Identity", , adCmdText)


It sure surprised me when someone first posted that a few years ago
and stated that worked well against a Jet database.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
  #15  
Old November 25th, 2007, 01:04 PM posted to microsoft.public.access.tablesdbdesign
RoyVidar
external usenet poster
 
Posts: 417
Default Split database

David W. Fenton wrote:
"Tony Toews [MVP]" wrote in
:

RoyVidar wrote:

Set rs = cn.Execute("SELECT @@Identity", , adCmdText)

It sure surprised me when someone first posted that a few years
ago and stated that worked well against a Jet database.


That's a feature of ADO, not of Jet.


If that was true, then the following shouldn't work

Sub DAO_Identity()

Dim rs As DAO.Recordset

With DBEngine(0)(0)

On Error Resume Next
.Execute "CREATE TABLE DAO_IdentityTest " & _
"(id Counter Primary Key, sometext Text(25))"
On Error GoTo 0
.Execute "INSERT INTO DAO_IdentityTest " & _
"(sometext) VALUES ('Just testing')"
Set rs = .OpenRecordset("SELECT @@Identity")
Debug.Print rs.Fields(0).Value

End With

End Sub

But it does (how reliable it is with concurrent users, I don't know).

Quoting from the book where I first encountered it (A2k Developers
Handbook, Sybex, 1999) p 197:

"The Jet 4 extensions also add support for querying the last-assigned
Auto-Number value using the same syntax as SQL Server

SELECT @@IDENTITY"

Jet 4 extensions, not ADO.

--
Roy-Vidar
  #16  
Old November 26th, 2007, 01:13 AM posted to microsoft.public.access.tablesdbdesign
Tony Toews [MVP]
external usenet poster
 
Posts: 3,776
Default Split database

RoyVidar wrote:

"The Jet 4 extensions also add support for querying the last-assigned
Auto-Number value using the same syntax as SQL Server

SELECT @@IDENTITY"

Jet 4 extensions, not ADO.


I'll be darned. Maybe I should go back and reread those books front
to back and see what else there is to learn.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:55 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.