Solved

Open Schema Primary Key

Posted on 2004-08-30
3
328 Views
Last Modified: 2008-02-07
Hi

I am trying to know the primary key( I mean "PK" not "Required" ) of a table. In VB, Connection's OpenSchema(adOpenPrimaryKey) works fine with SQL Server and Oracle i.e. returns only those fields in the database which are Primary Keys in their respective Tables but when i use this function with MS Access it returns some binary values which are not understandable.
I need to know the primary key of a Table in MS Access on the fly using Visual Basic. Optional(The Schema should be returned as a Recordset as it is for SQL Server and Oracle)
On the web, i found a way through DAO's Table.Field.Index property, But i am using ADO 2.6.

I repeate again:
How to know the primary key of a table in MS Access on the fly using Visual Basic-ADO 2.6 ?

Thanks
0
Comment
Question by:AtifAqeel
  • 2
3 Comments
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 50 total points
ID: 11930433
First, visit this page (one line):

http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q186/2/46.asp&NoWebContent=1

Then it would be something like this:

  Set rst = CurrentProject.Connection.OpenSchema(adSchemaPrimaryKeys, Array(Empty, Empty, "YourTableName"))
  Debug.Print rst!COLUMN_NAME

/gustav
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 12265927
Did this work for you?

/gustav
0
 

Author Comment

by:AtifAqeel
ID: 12274903
yes it did
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Error in query expression 3 37
Change AD password via MS Access DB 2 20
Prevent use of Microsoft Office application 9 55
Importing and Dropping Table in Access 11 25
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now