标题: VBA获取文件的值出现:无法记录所做的更改,因为您输入的值违反了 [打印本页] 作者: liyu12358 时间: 2016-5-25 13:59 标题: VBA获取文件的值出现:无法记录所做的更改,因为您输入的值违反了 VBA获取文件的值出现:法记录所做的更改,因为您输入的值违反了为此表或列定义的设置(例如,您所输入的值小于最小值或大于最大值)。请更正错误并重试
获取外部文件的数据,貌似第一天还有用,第二天用的时候就报这个错,查了资料但是还是无从下手,哪位大神帮忙看下,啥子情况
========================
Private Sub Command248_Click()
Dim i As Integer
Dim filepath As String
Dim ssql As String
Dim ssql1 As String
Dim Rs As New ADODB.Recordset
Dim j As Integer
Dim path As String
Dim sl As Integer
Dim cf As Integer
Dim gx As Integer
Dim DLG As FileDialog, vFile
sl = 0
cf = 0
gx = 0
Set DLG = Application.FileDialog(msoFileDialogOpen)
With DLG
.AllowMultiSelect = False
.ButtonName = "选择"
.InitialFileName = CurrentProject.path
' .Filters.Add "Graphics Files", "*.csv;", 1
.Filters.Add "Graphics Files", "*.csv", 1
End With
If DLG.Show = -1 Then
path = DLG.SelectedItems(1)
filepath = path
ConvertCSVToXls path
path = Replace(path, ".csv", ".xlsx")
mz = GetSheetName1(path, 1)
Set cnn = CreateObject("adodb.connection")
Set Rs = CreateObject("adodb.Recordset")
cnn.Open "provider=microsoft.ace.oledb.12.0;extended properties=excel 12.0;data source=" & path
sql = "select * from [" & mz & "]"
Rs.Open sql, cnn, 1, 1
cf = Rs.RecordCount
sql1 = "delete from 后台销售记录详情 "
opensql (sql1)
For j = 1 To Rs.RecordCount
ddid = False
khww = False
bbgl = False
hx = False
If IsNull(Rs("商家编码").Value) = False Then khww = True
'Rs("商家编码").Value这里报错如题错误,本来应该取到那个单元格值是:"5001+5006*2"
If IsNull(DLookup("订单ID", "后台销售记录", "订单ID ='" & Rs!订单编号.Value & "'")) = False Then ddid = True
If ddid = True And khww = True Then
Dim spbm As String
spbm = Rs!商家编码.Value
Call xzbbmx(Rs!订单编号.Value, Rs!商家编码.Value, Rs!购买数量.Value)
End If
Rs.MoveNext
Next
Rs.Close
cnn.Close
Set Rs = Nothing
Set cnn = Nothing
MsgBox ("智能匹配完成")
If Dir(path) <> "" Then
DeleteFiles path
End If
End If
Me![销售记录查询1].Requery
End Sub
=========================== 作者: roych 时间: 2016-5-25 14:47
贴源文件吧。里面有好几个自定义函数都不知道有没有问题。作者: liyu12358 时间: 2016-5-25 16:42