Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB Databases
|
Pro VB Databases Advanced-level VB coding questions specific to using VB with databases. Beginning-level questions or issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB Databases 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 July 1st, 2005, 06:28 AM
Registered User
 
Join Date: Nov 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to drop a field with primary key

I am using VB6 code to manage an Access database. I want to drop a field with primary key and then add another primary key to another field. I found some web pages mentioning about dropping contraint before dropping the field. However, the database, table, fields and primary key was created in Access so I do not know what its contraint name is. I tried db.Execute "ALTER TABLE myTable DROP CONSTRAINT ID" but got an error of "Check constraint ID doesn't exist".

What can I do?

Jeff
 
Old May 4th, 2006, 01:51 PM
Registered User
 
Join Date: May 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

RE: DBEngine(0)(0).TableDefs("Tablename").Indexes(0).N ame

Loop through the .Indexes collection of the Tabledefs("Tablename") object to find the .Name property of the index with the .Primary property set to True.

~ Shaun





Similar Threads
Thread Thread Starter Forum Replies Last Post
drop primary key MathLearner SQL Server 2000 1 January 4th, 2008 12:53 AM
Set table's primary key field using DAO VBA Versi Ray Pinnegar Access 2 May 31st, 2005 08:08 AM
unique primary key field in CR kelvinklein82 BOOK: Professional Crystal Reports for VS.NET 0 December 29th, 2004 11:52 AM
FOREIGN KEY and PRIMARY KEY Constraints junemo Oracle 10 June 15th, 2004 01:00 AM





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