|
本帖最后由 1588078/37 于 2019-6-20 16:45 编辑
运行时错误'2110'
"由于控件无法看到,尚未启用或其类型属于不接受焦点,因此无法将焦点移至该控件"
表用久了,可能会出现
偶尔出现
没附件,没得连接ERP数据库的没有数据
论坛上就看过11年有人问过
百度找不到同样问题 的
- Set dic = CreateObject("scripting.dictionary")
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- Set d2 = CreateObject("scripting.dictionary")
- With Me.ListView2
- If .ListItems.Count = 0 Then
- MsgBox "未添加入库项"
- Exit Sub
- End If
- If .ListItems.Count Then
- col = .ColumnHeaders.Count - 1
- ReDim arr(1 To .ListItems.Count, 1 To 5)
- For i = 1 To .ListItems.Count
- arr(i, 1) = .ListItems(i).SubItems(1)
- arr(i, 2) = .ListItems(i).SubItems(2)
- arr(i, 3) = .ListItems(i).SubItems(3)
- arr(i, 4) = .ListItems(i).SubItems(4)
-
- Next
- End If
- End With
- Call OpenErp
- Sql = "select A2,A1,A5 ,A4 from (select CUS_OS_NO as A1,PRD_NO as A2,max(EST_DD) as A3,sum(QTY) as A4,Rem as A5 from (select t1.CUS_OS_NO as CUS_OS_NO,t1.PRD_NO as PRD_NO ,t1.EST_DD as EST_DD,t1.QTY-isnull(t1.QTY_PS,0)as QTY ,t1.Rem as Rem from TF_POS t1 left join MF_POS t2 on t1.OS_NO=t2.OS_NO where t1.OS_ID='SO' and CLS_ID<>'T' and t1.QTY-isnull(QTY_PS,0)-isnull(QTY_PRE,0)>0 AND t2.CUS_NO='11001' union all select t2.OS_NO as CUS_OS_NO,t2.PRD_NO as PRD_NO,'' as EST_DD ,(-1)*t2.QTY as QTY ,t2.HH_NO as Rem from MF_XH t1 left join TF_XH t2 on t1.XH_NO=t2.XH_NO where t1.SA_NO is null) x1 group by CUS_OS_NO,PRD_NO,Rem) t LEFT JOIN PRDT tt on t.A2=tt.PRD_NO where t.A4>0 order by A3,A2,A1,A5"
- DBRst.Open Sql, ConnDB, adOpenKeyset, adLockOptimistic
- brr = DBRst.GetRows
- Call CloseErp
- For i = 0 To UBound(brr, 2)
- dic(brr(0, i)) = dic(brr(0, i)) + 1
- d(brr(0, i) & "," & dic(brr(0, i))) = brr(1, i) & "," & brr(2, i)
- d1(brr(0, i) & "," & dic(brr(0, i)) & "," & brr(1, i) & "," & brr(2, i)) = brr(3, i)
- Next
- For i = 1 To UBound(arr)
- If dic.exists(arr(i, 1)) Then
- x = 0
- kmm = 0
- For k = 1 To dic(arr(i, 1))
- kk = arr(i, 4) - kmm
- x = d1(arr(i, 1) & "," & k & "," & d(arr(i, 1) & "," & k))
- If x > 0 Then
- If kk <= x Then
- arr(i, 5) = arr(i, 5) & "|" & d(arr(i, 1) & "," & k) & "," & kk
- d1(arr(i, 1) & "," & k & "," & d(arr(i, 1) & "," & k)) = x - kk
- Exit For
- Else
- arr(i, 5) = arr(i, 5) & "|" & d(arr(i, 1) & "," & k) & "," & d1(arr(i, 1) & "," & k & "," & d(arr(i, 1) & "," & k))
- kmm = kmm + x
- d1(arr(i, 1) & "," & k & "," & d(arr(i, 1) & "," & k)) = 0
- End If
- End If
- Next
- End If
- Next
- For i = 1 To UBound(arr)
- xo = 0
- If arr(i, 5) Like "*|*" Then
- pp = Split(arr(i, 5), "|")
- For ii = 1 To UBound(pp)
- xo = xo + Val(Split(pp(ii), ",")(2))
- Next
- If xo <> Val(arr(i, 4)) Then
- s = s & "," & arr(i, 1) & "订单不足:" & arr(i, 4) - xo
- End If
- Else
- s = s & "," & arr(i, 1) & "订单不足:" & arr(i, 4)
- End If
- Next
- If Len(s) Then
- MsgBox Mid(s, 2)
- Exit Sub
- End If
- dysl = 3
- ReDim crr(1 To 100, 1 To 7)
- For i = 1 To UBound(arr)
- pp = Split(arr(i, 5), "|")
- For ii = 1 To UBound(pp)
- m = m + 1
- crr(m, 1) = m
- crr(m, 3) = arr(i, 1)
- crr(m, 4) = arr(i, 2)
- If crr(m, 4) Like "*励磁*" Or crr(m, 4) Like "*未浸漆*" Then
- dysl = 4
- End If
- crr(m, 5) = arr(i, 3)
- crr(m, 2) = "*" & Split(pp(ii), ",")(0) & "/" & Split(pp(ii), ",")(1) & "*"
- crr(m, 6) = Split(pp(ii), ",")(2)
- crr(m, 7) = "*" & arr(i, 1) & "*"
- tt = tt + Val(crr(m, 6))
- Next
- crr(m + 1, 1) = "合计"
- crr(m + 1, 6) = tt
- Next
- Call OpenErp
- Sql = "select max(XH_NO) from MF_XH"
- DBRst.Open Sql, ConnDB, adOpenKeyset, adLockOptimistic
- If DBRst.EOF = True Then
- dh = Format(Now(), "yyyymmdd") & "001"
- Else
- arr = DBRst.GetRows
- Call CloseErp
- If IsNull(arr(0, 0)) Or Format(arr(0, 0), "00000000") < Format(Now(), "yyyymmdd") Then
- dh = Format(Now(), "yyyymmdd") & "001"
- Else
- dh = arr(0, 0) + 1
- End If
- End If
- tm = Now()
- Call OpenErp
- Sql = "select * from MF_XH"
- DBRst.Open Sql, ConnDB, adOpenKeyset, adLockOptimistic
- With DBRst
- .AddNew
- .Fields(0).Value = dh
- .Fields(1).Value = tm
- .Update
- End With
- Call CloseErp
- Call OpenErp
- Sql = "select * from TF_XH"
- DBRst.Open Sql, ConnDB, adOpenKeyset, adLockOptimistic
- With DBRst
- For i = 1 To m
- .AddNew
- .Fields(0).Value = dh
- .Fields(1).Value = Split(Replace(crr(i, 2), "*", ""), "/")(0)
- .Fields(2).Value = crr(i, 3)
- .Fields(3).Value = crr(i, 6)
- .Fields(4).Value = Split(Replace(crr(i, 2), "*", ""), "/")(1)
- .Update
- Next
- End With
- TextBox4.Text = dh
- CommandButton1.Visible = False
- CommandButton2.Visible = False
- CommandButton3.Visible = False
- CommandButton4.Visible = False
- CommandButton5.Visible = False
- CommandButton6.Visible = True
- TextBox1.Enabled = False
- TextBox3.Enabled = False
- With Sheet1
- .[g2] = "SA19" & Format(Now(), "mm") & 0 & "_______"
- .[g3] = dh
- .[d3] = "单号:" & Format(tm, "yyyy/mm/dd hh:mm:ss")
- .Range("A5:Z1000").ClearContents
- .Cells.Borders.LineStyle = xlNone
- .[A5].Resize(m + 1, 7) = crr
- With .Range(.Cells(5, 1), .Cells(m + 4, 7))
- .Sort Key1:=.Range("c5"), Order1:=1
- End With
- For i = 5 To m + 4
- .Cells(i, 1) = i - 4
- Next
- m = IIf(m < 18, 18, m)
- With .Range(.Cells(3, 1), .Cells(m + 5, 7))
- .Borders.LineStyle = xlContinuous
- .BorderAround xlContinuous, xlMedium
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- Sheet1.PrintOut Copies:=dysl
- Exit Sub
- End With
复制代码
|
|