Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA 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 28th, 2004, 11:10 AM
Registered User
 
Join Date: Sep 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to peace
Default Unique Record Identifier

Hi,
I'm linking tables with DoCmd.TransferDatabase command from an SQL DB, but for some tables "select unique record identifier" dialog appears. I know that's because primary key for that tables are not defined. Is there a way to bypass this dialog with code? Otherwise user will have to click cancel for 5-6 times each time she runs the program.
 
Old December 6th, 2005, 12:03 PM
Registered User
 
Join Date: Dec 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi there,

There's a good full example of this at: http://tinyurl.com/9l55d (look for Brenda's post near the end) but as the example is very lengthy, the basic steps are as follows:

- Delete the old linekd table with deleteobject if necessary
- Create a new tabledef with createtabledef
- Set the .connect and .sourcetable properties of this tabledef
- append it to the TableDefs collection
- refresh the tabledefs collection (tabledefs.refresh)
- if you need more than read access to the tables, then you need to specify in code the unique record identifier. You can do this with a docmd.runsql sending a "CREATE UNIQUE INDEX" command to the DB. See Brenda's example on the link above.

Hope that helps - let me know,

Al
http://www.integritec.co.uk






Similar Threads
Thread Thread Starter Forum Replies Last Post
passing unique record from form to form Baconant Beginning VB 6 1 January 2nd, 2008 06:20 PM
Insert Record Fails W/ Unique Constraint snw C# 0 September 2nd, 2005 02:14 PM
Counting unique record dlamarche Access 5 March 22nd, 2005 08:51 AM
Identifier Expected syncmaster VB.NET 2002/2003 Basics 1 September 2nd, 2004 03:34 AM
Updating Unique Identifier foreign key to NULL jraymond VB Databases Basics 0 June 16th, 2003 01:51 PM





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