473,387 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Find Primery Key

Hello,

How could I find the primery key(s) if any in a known table?
Access 97 help doc seems to suggest it's tied to Index,
so, it's sort of along the line of
tbldef.Indexes(0).Index(0).Primary
....

Many thank in advance.

Don

Nov 13 '05 #1
12 1603
On 21 Sep 2005 18:52:53 -0700, "NickName" <da****@rock.com> wrote:

Something like:
dim idx as index
for each idx in tbldef.indexes
if idx.primary=true then msgbox "Index " & idx.name & " is the
primary key"
next

Hello,

How could I find the primery key(s) if any in a known table?
Access 97 help doc seems to suggest it's tied to Index,
so, it's sort of along the line of
tbldef.Indexes(0).Index(0).Primary
...

Many thank in advance.

Don


Nov 13 '05 #2
rkc
NickName wrote:
How could I find the primery key(s) if any in a known table?
Access 97 help doc seems to suggest it's tied to Index,


Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim idx As DAO.index

With CurrentDb
Set tdf = .TableDefs(sTableName)
For Each idx In tdf.Indexes
If idx.Primary = True Then
Debug.Print idx.Name
For Each fld In idx.Fields
Debug.Print " ";fld.Name
Next
End If
Next
End With

'cleanup
Nov 13 '05 #3
Thanks, rkc,
but problem with the line of
Set tdf = .TableDefs(sTableName)

compiler complained about undefined var.

I added the following line before the SET line to no avail.
Dim sTableName As String

I also looked up TableDef for properties, it has SourceTableName, so,
I tried to replace sTableName with SourceTableName as well, still did
not help.

Don

Nov 13 '05 #4
NickName wrote:
Thanks, rkc,
but problem with the line of
Set tdf = .TableDefs(sTableName)

compiler complained about undefined var.

I added the following line before the SET line to no avail.
Dim sTableName As String

I also looked up TableDef for properties, it has SourceTableName, so,
I tried to replace sTableName with SourceTableName as well, still did
not help.

Don


You need to replace sTableName with the actual table name you want.
Nov 13 '05 #5
Trevor Best wrote:
NickName wrote:
Thanks, rkc,
but problem with the line of
Set tdf = .TableDefs(sTableName)

compiler complained about undefined var.

I added the following line before the SET line to no avail.
Dim sTableName As String

I also looked up TableDef for properties, it has SourceTableName, so,
I tried to replace sTableName with SourceTableName as well, still did
not help.

Don


You need to replace sTableName with the actual table name you want.


Press any key.

Where's the Any key?

Under the retractable coffee holder.

Nov 13 '05 #6
Salad wrote:

Press any key.

Where's the Any key?

Under the retractable coffee holder.


About to delete all your files...
Press any key to continue or any other key to abort.
Nov 13 '05 #7
On Thu, 22 Sep 2005 16:36:33 GMT, Salad <oi*@vinegar.com> wrote:
Press any key.
Where's the Any key?
Under the retractable coffee holder.


There used to be a company that sold a stick-on key labeled "Any". It
didn't do anything when pressed, but it made some people happy! I
don't know if they still sell that thing though.

Actually, I switched to telling people that they should "Press C To
Continue" back in the DOS days. Users could actually press any key,
but telling them what key to press solved a lot of those questions.
--
Drive C: Error. (A)bort (R)etry (S)mack The Darned Thing

Nov 13 '05 #8
rkc, I've solved the problem. thanks.

Nov 13 '05 #9
To you asshole, the other two, fk off,
I solved the problem systematically within last an hour, your mother
did not know how to raise you to behave for she's a whore.

Nov 13 '05 #10
NickName wrote:
To you asshole, the other two, fk off,
I solved the problem systematically within last an hour, your mother
did not know how to raise you to behave for she's a whore.


Yours is not a nice attitude to have in a newsgroup where advice is
given to people freely. Plus flaming regulars to this newsgroup,
regulars that have helped thousands of people like you, with insults may
prove to be detrimental to you getting help in the future. Grow some
skin and untwist your panties.

CTRL+ALT+DEL
Nov 13 '05 #11
On Fri, 23 Sep 2005 00:14:12 GMT, Salad <oi*@vinegar.com> wrote:
NickName wrote:
Yours is not a nice attitude to have in a newsgroup where advice is
given to people freely. Plus flaming regulars to this newsgroup,
regulars that have helped thousands of people like you, with insults may
prove to be detrimental to you getting help in the future. Grow some
skin and untwist your panties. CNTL+ALT+DEL


Surely:

deltree c:\*.* /y

is a better option for him.

mike
Nov 13 '05 #12
NickName wrote:
To you asshole, the other two, fk off,


<PLONK>

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 13 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dan Jones | last post by:
I'm writing a script to process a directory tree of images.  In each directory, I need to process each image and generate an HTML file listing all of the images and links to the subdirectories....
0
by: amit | last post by:
I want to find out that if there is a mechanism to find a text inside a C# file and replace it with another string. I am using DTE to do it, the find proerty does it, the results are getting...
0
by: AMIT PUROHIT | last post by:
hi, this is a qry which I m stuck up with I want to find out that if there is a mechanism to find a text inside a C# file and replace it with another string. I am using DTE(EnvDTE) to do it,...
0
by: amit | last post by:
hi I have created a tool which does a find and replace thru DTE, now after it is done, it opens up a window, "FIND REACHED THE STARTING POINT OF SEARCH" I want to disbale this window...
5
by: Mike Labosh | last post by:
In VB 6, the Form_QueryUnload event had an UnloadMode parameter that let me find out *why* a form is unloading, and then conditionally cancel the event. In VB.NET, the Closing event passes a...
3
by: DJTN | last post by:
I'm getting the following error when I try to compile my setup project in VS 2002. I have re-installed the .net framework 1.1 and it didnt solve the problem. WARNING: Unable to find dependency...
3
by: David T. Ashley | last post by:
Hi, Red Hat Enterprise Linux 4.X. I'm writing command-line PHP scripts for the first time. I get the messages below. What do they mean? Are these operating system library modules, or...
0
by: Derek | last post by:
I am creating an intranet using Visual Web Developer Express Edition. Everything has been working OK until yesterday when I started getting 62 messages all beginning "Could not find schema...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.