Prev: goooo
Next: Wiener Access Stammtisch (Nr. 78): Einladung f�r den 13.04.2010 ("Pizzeria Fantastica" Kagraner Platz)
From: aligahk06 on 6 Apr 2010 02:59 Dear All, Could it be possible to find out primary key in a table and then redine the primary key . Any help? Rgds, Aligahk0
From: Stefan Hoffmann on 6 Apr 2010 04:00
hi, On 06.04.2010 08:59, aligahk06 wrote: > Could it be possible to find out primary key in a table and then redine the > primary key . Sure, open the table in design view, and locate the key symbole on the left side of each field. Mark the new fields and press the key button. To do it in VBA you need to inspect the Indexes collection of a TableDef object, e.g. Dim db As DAO.Database Dim fd As DAO.Field Dim ix As DAO.Index Dim td As DAO.TableDef Set db = CurrentDb Set td = db.TableDefs.Item("Information") For Each ix In td.Indexes Debug.Print ix.Name; If ix.Primary Then Debug.Print ":"; For Each fd In ix.Fields Debug.Print " "; fd.Name; Next fd End If Debug.Print Next ix Set td = Nothing Set db = Nothing To redefine the primary key you need to remove this index from the Indexes collection and add an new index with Primary = True. mfG --> stefan <-- |