修改一下楼上的:
Private Sub Command9_Click()
Dim ctl As Control
Dim Str As String
Dim ctlName As String
Dim ctlVal As String
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
ctlName = ctlName & "," & ctl.Name
ctlVal = ctlVal & "," & FH("出库表", ctl.Name) & Nz(ctl.Value) & FH("出库表", ctl.Name)
End If
Next
Str = "INSERT INTO 出库表 (" & Mid(ctlName, 2) & ") SELECT " & Mid(ctlVal, 2)
DoCmd.RunSQL Str
End Sub
Function FH(ByVal tb As String, ByVal ZD As String) As String
Select Case CurrentDb.TableDefs(tb)(ZD).Type
Case dbDate
FH = "#"
Case dbText
FH = "'"
Case dbMemo
FH = "'"
Case Else
FH = ""
End Select
End Function