包含重復項的表為infoData,表中字段為ID,企業(yè)名稱,注冊地址,企業(yè)負責人,經(jīng)營范圍,建臨時表tbltemp
在窗體中建個按鈕,按鈕事件中寫代碼如下:
Private Sub Command0_Click()
Dim strsql As String
Dim strsql2 As String
Dim strsql3 As String
Dim strsql4 As String
strsql = "select distinct 企業(yè)名稱,注冊地址,企業(yè)負責人,經(jīng)營范圍 into tbltemp from InfoData"
strsql2 = "delete from InfoData "
strsql3 = "insert into InfoData select * from tbltemp"
strsql4 = "delete from tbltemp"
DoCmd.SetWarnings False
DoCmd.RunSQL strsql
DoCmd.SetWarnings False
DoCmd.RunSQL strsql2
DoCmd.SetWarnings False
DoCmd.RunSQL strsql3
DoCmd.SetWarnings False
DoCmd.RunSQL strsql4
End Sub
在窗體中建個按鈕,按鈕事件中寫代碼如下:
Private Sub Command0_Click()
Dim strsql As String
Dim strsql2 As String
Dim strsql3 As String
Dim strsql4 As String
strsql = "select distinct 企業(yè)名稱,注冊地址,企業(yè)負責人,經(jīng)營范圍 into tbltemp from InfoData"
strsql2 = "delete from InfoData "
strsql3 = "insert into InfoData select * from tbltemp"
strsql4 = "delete from tbltemp"
DoCmd.SetWarnings False
DoCmd.RunSQL strsql
DoCmd.SetWarnings False
DoCmd.RunSQL strsql2
DoCmd.SetWarnings False
DoCmd.RunSQL strsql3
DoCmd.SetWarnings False
DoCmd.RunSQL strsql4
End Sub