Composite Keys in VB4.0ee 
Author Message
 Composite Keys in VB4.0ee

Hi There

I am a novice programmer using VB4.0 enterprise edition.

I have one query: How do you define compound keys, ie.keys consisting of more
than one field in a table, using the access database?

Any help will be appreciated...

tia

Duncan



Sun, 06 Dec 1998 03:00:00 GMT  
 Composite Keys in VB4.0ee

Quote:
> I have one query: How do you define compound keys, ie.keys consisting of more
> than one field in a table, using the access database?

I'm not sure if you mean in Access or in your VB code. In Access go to table design and highlight multiple
rows (which represent fields here), right-click to get the popup menu and pick "Set Primary Key".
In VB you need to check out the Indexes collection of your tabledef. for example:

Dim DB as Database

Set DB = DBEngine.OpenDatabase("MyData.mdb")

' this will set the first two fields in your
' table as a composite primary key
DB.TableDefs("myTable").Indexes(1).Primary = True
DB.TableDefs("myTable").Indexes(2).Primary = True
DB.TableDefs("myTable").Indexes(1).Unique = True
DB.TableDefs("myTable").Indexes(2).Unique = True

Hope this helps ...

Quote:
> Duncan

- Randy Shepardson -


Sun, 06 Dec 1998 03:00:00 GMT  
 Composite Keys in VB4.0ee

Quote:

>Hi There
>I am a novice programmer using VB4.0 enterprise edition.
>I have one query: How do you define compound keys, ie.keys consisting of more
>than one field in a table, using the access database?
>Any help will be appreciated...
>tia
>Duncan

Look in the help file under <Index objects | Index objects, Indexes
Collections>. There is an example there on how to do this as well as
other properties you may set for your indexes. In short, you first
create an index, then add (append) as many fields to that index as you
want. Set the properties of the index that you want (eg unique,
primary, etc) and then update the table definition.
Fred Baptiste



Mon, 07 Dec 1998 03:00:00 GMT  
 Composite Keys in VB4.0ee

Quote:

>I have one query: How do you define compound keys, ie.keys consisting of more
>than one field in a table, using the access database?

If you're doing this in Access, open the indexes window in table
design view and simply add more than one field to the index. If
you need to do this in VB code, search help for the Index
object/Indexes collection. It's pretty much the same process as
appending a field to a table.

Joe

Never underestimate the power of a WAG.

http://www.citilink.com/~jgarrick



Wed, 09 Dec 1998 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. SQL and Composite Keys

2. Composite Key

3. SEEK via composite key

4. How does lookup controls work with composite keys

5. Active data driver and linking tables through multiple fields (composite key)

6. How does lookup controls work with composite keys

7. VB4.0EE 32bit Error writing EXE w/Rmt Supt files

8. Is VB4.0EE Good ?

9. VB5.0EE and Viper

10. Help with DBCombo box in VB.5.0EE

11. Help with pics in data base in VB5.0EE

 

 
Powered by phpBB® Forum Software