|
程式码入下! 各位大大看看有谁可以帮我解决这个问题
资料无法正确导入到access
Sub 对access增加资料()
Dim cnn As New ADODB.Connection
Dim RST As New ADODB.Recordset
Dim Stpath, strSQL As String
Dim A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18
A1 = Me.TextBox1.Value
A2 = Me.TextBox2.Value
A3 = Me.ComboBox2.Value
A4 = Me.TextBox3.Value
A5 = Me.TextBox4.Value
A6 = Me.TextBox5.Value
A7 = Me.TextBox6.Value
A8 = Me.TextBox7.Value
A9 = Me.TextBox8.Value
A10 = Me.TextBox9.Value
A11 = Me.TextBox10.Value
A12 = Me.TextBox11.Value
A13 = Me.TextBox12.Value
A14 = Me.TextBox13.Value
A15 = Me.TextBox14.Value
A16 = Me.TextBox15.Value
A17 = Me.TextBox16.Value
A18 = Me.TextBox17.Value
Stpath = ThisWorkbook.Path & Application.PathSeparator & "Amanufactory1.mdb"
cnn.Open "provider=Microsoft.jet.OLEDB.4.0;data source=" & Stpath
RST.Open "ahrlist1", cnn
strSQL = "Insert Into ahrlist1(unit_name,class_name,state_name, card_num,list_name,level,job,m_name,pm_num1,pm_num2,pm_num3,um_num1,um_num2,um_num3,va_date,b_date,leave_date,note) " & _
"Values('" & A1 & "','" & A2 & "','" & A3 & "','" & A4 & "','" & A5 & "','" & A6 & "','" & A7 & "','" & A8 & "','" & A9 & "','" & A10 & "','" & A11 & "','" & A12 & "','" & A13 & "','" & A14 & "','" & A15 & "','" & A16 & "','" & A17 & "','" & A18 & "')"
cnn.Execute strSQL
RST.Close
cnn.Close
Dim i
i = ListView1.ListItems.Count
ListView1.ListItems.Add , , TextBox1
ListView1.ListItems(i + 1).SubItems(1) = TextBox1
ListView1.ListItems(i + 1).SubItems(2) = TextBox2
ListView1.ListItems(i + 1).SubItems(3) = ComboBox2
ListView1.ListItems(i + 1).SubItems(4) = TextBox3
ListView1.ListItems(i + 1).SubItems(5) = TextBox4
ListView1.ListItems(i + 1).SubItems(6) = TextBox5
ListView1.ListItems(i + 1).SubItems(7) = TextBox6
ListView1.ListItems(i + 1).SubItems(8) = TextBox7
ListView1.ListItems(i + 1).SubItems(9) = TextBox8
ListView1.ListItems(i + 1).SubItems(10) = TextBox9
ListView1.ListItems(i + 1).SubItems(11) = TextBox10
ListView1.ListItems(i + 1).SubItems(12) = TextBox11
ListView1.ListItems(i + 1).SubItems(13) = TextBox12
ListView1.ListItems(i + 1).SubItems(14) = TextBox13
ListView1.ListItems(i + 1).SubItems(15) = TextBox14
ListView1.ListItems(i + 1).SubItems(16) = TextBox15
ListView1.ListItems(i + 1).SubItems(17) = TextBox16
ListView1.ListItems(i + 1).SubItems(18) = TextBox17
End Sub
|
|