|
Sub FillInvoice_Click()
Dim con As New Connection, rs1 As New Recordset, rs2 As New Recordset
con.Open "Provider=SQLOLEDB.1;User ID=software;Data Source=*********;Initial Catalog=OceaniaERP;Password=********"
rs1.Open "select * from OC_CustomsDeclaration_Item where CustomsDeclarationNum='" & Sheets("workstation").Range("B2") & "'", con, 1, 1
rs2.Open "select * from OC_CustomsDeclaration where CustomsDeclarationNum='" & Sheets("workstation").Range("B2") & "'", con, 1, 1
Sheets("TempInvoice").Range("InvoiceNo") = Sheets("workstation").Range("B2") & "YH"
Sheets("TempInvoice").Range("InvoiceDate") = rs2("DeclarationDate")
If rs1.RecordCount = 1 Then
Sheets("TempInvoice").Range("A13") = rs1("CNDeclaration")
Sheets("TempInvoice").Range("A13").WrapText = True
Sheets("TempInvoice").Range("B13") = rs1("DeclarationElements")
Sheets("TempInvoice").Range("B13").WrapText = True
Sheets("TempInvoice").Range("D13") = rs1("Quality")
Sheets("TempInvoice").Range("E13") = rs1("UnitPrice")
Sheets("TempInvoice").Range("F13") = rs1("TotalPrice")
Else
Sheets("TempInvoice").Range("15:" & 15 + rs1.RecordCount - 2).Insert
i = 0
Do While Not rs1.EOF
Sheets("TempInvoice").Range("A" & 14 + i) = rs1("CNDeclaration")
Sheets("TempInvoice").Range("A" & 14 + i).WrapText = True
Sheets("TempInvoice").Range("B" & 14 + i) = rs1("DeclarationElements")
Sheets("TempInvoice").Range("B" & 14 + i).WrapText = True
Sheets("TempInvoice").Range("D" & 14 + i) = rs1("Quality")
Sheets("TempInvoice").Range("E" & 14 + i) = rs1("UnitPrice")
Sheets("TempInvoice").Range("F" & 14 + i) = rs1("TotalPrice")
Sheets("TempInvoice").Range(14 + i & ":" & 14 + i).EntireRow.AutoFit
rs2.MoveNext
i = i + 1
Loop
End If
不知道啥问题,调试后,光标一直停留在 rs2.MoveNext 上,好像取不到下一行数据。
新人一枚,求解 ~
|
|