设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

12
返回列表 发新帖
楼主: wjb5645
打印 上一主题 下一主题

[其它] 用VBA设定表的主关键字

[复制链接]
11#
发表于 2003-6-12 20:20:00 | 只看该作者
Private Sub 命令6_Click()
Dim dbs As DAO.Database
    Dim tdf As DAO.TableDef
     Dim idxNew As DAO.Index
     
     Set dbs = OpenDatabase("C:\Documents and Settings\administrator\My Documents\db1.mdb")
    Set tdf = dbs!表1

    With tdf
        ' Create new index, create and append Field
        ' objects to its Fields collection.
        Set idxNew = .CreateIndex("NewIndex")

        With idxNew
            .Fields.Append .CreateField("dfas")
               idxNew.Primary = True
            
        End With

        ' Add new Index object to the Indexes collection
        ' of the Employees table collection.
       .Indexes.Append idxNew
     
        .Indexes.Refresh
  End With






   
End Sub
12#
 楼主| 发表于 2003-6-12 21:18:00 | 只看该作者
非常感激sunredday大侠,帮我解决了大问题.
这个论坛高手很多,能耐心地有救苦救难风范的侠客不多.
再次感谢sunredday大侠!!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-9-21 22:18 , Processed in 0.089050 second(s), 23 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表