Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB Databases
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 1st, 2005, 06:28 AM
Registered User
 
Join Date: Nov 2003
Location: , , .
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
Reply With Quote
  #2 (permalink)  
Old May 4th, 2006, 01:51 PM
Registered User
 
Join Date: May 2006
Location: Bremerton, WA, USA.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 05:00 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.