|
-
Jun 20th, 2009, 06:24 AM
#1
Thread Starter
New Member
[RESOLVED] Creating a Primary Key
Hi - I am using VB6 to create a primary key to an existing table in an Access database. It works but when I attempt to run the 'SEEK' command on that table a message returns saying that the primary key could not be found. Conversely, if I manually open the table and set the primary key the 'SEEK' command works. The code I am using for setting the primary key is as follows...
Dim strSQL As String
strSQL = "ALTER TABLE tablename ADD PRIMARY KEY(fieldname)"
dbs.Execute strSQL, dbFailOnError
As stated I know this works because I have opened the table afterwards and seen the primary key icon correctly established against the correct field so I can only imagine the code is missing some form of update command perhaps. Having said that if I close the database and then re-open it after running the above code the same error occurs. This has really got me stumped!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|