2010-08-09 73 views

回答

2

你看過連續的表格和數據表嗎?

這是很少複製數據庫中的

+1

如果您想張貼這些句子作爲一個單獨的答案,我已經投了他們兩個! – 2010-08-09 22:00:21

0

代碼InsertRows電子表格的行爲是個好主意:插入行拖行之間

首先創建一個temporarilytable然後處理這個表像主表

和代碼是工作與我 和這裏的代碼:

Sub InsertRows() 
    On Error GoTo ErrorNu 
    Dim SQLP As String 
    Dim Con As New ADODB.Connection 
    Dim Conx As New ADODB.Connection 
    Dim Rst As New ADODB.Recordset 
    Dim Rs As New ADODB.Recordset 
    Dim Rsx As New ADODB.Recordset 
    Dim Rn As New ADODB.Recordset 
    Dim Rd As New ADODB.Recordset 
    Dim Num As Long 
    Dim intRows 
    Dim arrEmployees As Variant 
    Dim x As Integer, Y As Integer 

    Set Con = CurrentProject.Connection 
Con.BeginTrans 

sqlo = " select max(AutoRec)as maxa from Note_Custom " 
Set Rn = Con.Execute(sqlo) 


SQLP = " SELECT AutoRec, TextCOspoId, OuerM,Note" 
SQLP = SQLP & " , TextBillId,NuCOspoId,dateTybe FROM Note_Custom ORDER BY AutoRec" 

Rs.Open SQLP, Con, adUseClient, adOpenStatic, adCmdText 

sqlo = " UPDATE Note_Custom SET TextBillId = ''" 
sqlo = sqlo & " WHERE AutoRec > " & 0 
Con.Execute (sqlo) 


intRows = Val(Rn!maxa) 
Num = 1 
arrEmployees = Rs.GetRows(intRows) 
Y = 0 
    For x = 0 To intRows - 1 
If x = Val(SelTop - 1) Then 
Y = 1 
Rs.AddNew 
Rs![AutoRec] = arrEmployees(0, x) 
Rs![TextBillId] = 1 
Rs.Update 
End If 
Rs.AddNew 
Rs![AutoRec] = arrEmployees(0, x) + Y 
Rs![TextCOspoId] = arrEmployees(1, x) 
Rs![OuerM] = arrEmployees(2, x) 
Rs![Note] = arrEmployees(3, x) 
Rs![NuCOspoId] = arrEmployees(5, x) 
Rs![dateTybe] = arrEmployees(6, x) 


Rs![TextBillId] = 1 
Rs.Update 
    Next x 
    sqlo = "DELETE * FROM Note_Custom where TextBillId = """"" 
Con.Execute (sqlo) 
Con.CommitTrans 
SelFiled = Me.SelTop 
Me.Requery 
sqlo = "SELECT Last(AutoRec) AS LastAuto,First(AutoRec) AS FirstAuto,Count(AutoRec) AS CountAuto FROM Note_Custom" 
    Set Rd = Con.Execute(sqlo) 
If Me.SelTop <> AutoRec Or Rd!LastAuto <> Rd!CountAuto Then 
Refix 
End If 
DoCmd.GoToRecord , , acGoTo, SelFiled 
'Me.SelTop = SelFiled 
If RecType = False Then 
Forms![Ncustom]!Edite.Enabled = True 
Forms![Ncustom]!Viewer1.Enabled = False 
Forms![Ncustom]!DELETE.Enabled = False 
End If 
arrEmployees = Empty 
Rs.Close 
Con.Close 
Set Rs = Nothing 
Set Con = Nothing 
Exit Sub 
ErrorNu: 
SelFiled = Me.SelTop 
Me.Requery 
Me.SelTop = SelFiled 
End Sub