Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Open Schema Primary Key

Posted on 2004-08-30
3
Medium Priority
?
364 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 52

Accepted Solution

by:
Gustav Brock earned 150 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 52

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

876 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