📄 form3.frm
字号:
Me.DoubleList.Clear
'-----------------------------------------------------
If SourceList.Selected(SourceList.ListIndex) Then
SourceRst.Filter = "Class='" & SourceList.List(SourceList.ListIndex) & "'"
DestRst.Filter = "DoClass='" & SourceList.List(SourceList.ListIndex) & "'"
a = DestRst.RecordCount
Select Case SourceRst![dotype]
Case 0
If SourceRst![DisplayType] = "1" Then
Me.DoubleList.Visible = True
Me.DoubleAdd.Visible = True
Me.DoubleDel.Visible = True
If a > 0 Then
DestRst.MoveFirst
For b = 1 To a
DoubleList.AddItem DestRst![DisValue]
DestRst.MoveNext
Next
End If
Else
Me.SqlList.Visible = True
s = ""
j = 0
For i = Len(SourceRst![valuedisplay]) - 1 To 1 Step -1
If Mid(SourceRst![valuedisplay], i, 1) = "|" Then
Exit For
Else
s = Mid(SourceRst![valuedisplay], i, 1) & s
End If
Next
l = SourceRst![DoSource]
Rst1.Open l, GetConnect, adOpenStatic, adLockReadOnly
i = Rst1.RecordCount
'MsgBox i
If i > 0 Then
Rst1.MoveFirst
For j = 1 To i
If IsNull(Rst1.Fields(s).Value) Then
Else
SqlList.AddItem Rst1.Fields(s).Value
If a > 0 Then
DestRst.MoveFirst
For b = 1 To a
If DestRst![DisValue] = SqlList.List(SqlList.ListCount - 1) Then
SqlList.Selected(SqlList.ListCount - 1) = True
End If
DestRst.MoveNext
Next
End If
End If
Rst1.MoveNext
Next
End If
End If
Case 1
Me.SqlList.Visible = True
s = ""
j = 0
For i = 1 To Len(SourceRst![valuedisplay])
If Mid(SourceRst![valuedisplay], i, 1) = "|" Then
If j Mod 2 = 1 Then
SqlList.AddItem s
If a > 0 Then
DestRst.MoveFirst
For b = 1 To a
If DestRst![DisValue] = SqlList.List(SqlList.ListCount - 1) Then
SqlList.Selected(SqlList.ListCount - 1) = True
End If
DestRst.MoveNext
Next
End If
End If
j = j + 1
s = ""
Else
s = s & Mid(SourceRst![valuedisplay], i, 1)
End If
Next
Case 2
Me.SqlList.Visible = True
Me.SqlList.AddItem "是"
Me.SqlList.AddItem "否"
If a > 0 Then
DestRst.MoveFirst
For b = 1 To a
If DestRst![DisValue] = "是" Then
SqlList.Selected(0) = True
Else
SqlList.Selected(1) = True
End If
DestRst.MoveNext
Next
End If
Case 3
Me.DataBeginLabel.Visible = True
Me.DateBegin.Visible = True
If a > 0 Then
DestRst.MoveFirst
Me.DateBegin.Value = DestRst![DisValue]
End If
Case 4
Me.DataBeginLabel.Visible = True
Me.DateBegin.Visible = True
Me.DateEndLabel.Visible = True
Me.DateEnd.Visible = True
If a > 0 Then
DestRst.MoveFirst
s = ""
j = 0
For i = 1 To Len(DestRst![DisValue])
If Mid(DestRst![DisValue], i, 1) = "|" Then
If j = 0 Then
Me.DateBegin.Value = s
End If
If j = 1 Then
Me.DateEnd.Value = s
End If
j = j + 1
s = ""
Else
s = s & Mid(DestRst![DisValue], i, 1)
End If
Next
' Me.DateBegin.Value = Left(DestRst![DisValue], 8)
' Me.DateEnd.Value = Mid(DestRst![DisValue], 10, 8)
End If
Case 5
Me.WriteValueLabel.Caption = SourceRst![DoSource]
Me.WriteValue.Left = Me.WriteValueLabel.Left + Me.WriteValueLabel.Width + 100
Me.WriteValue.Visible = True
Me.WriteValueLabel.Visible = True
If a > 0 Then
DestRst.MoveFirst
Me.WriteValue.Text = DestRst![DisValue]
End If
End Select
End If
End Sub
Private Sub SourceList_Click()
Dim i As Long, j As Long
Debug.Print CurrentSource
If CurrentSource >= 0 And CurrentSource <> SourceList.ListIndex Then
DestRst.Filter = "DoClass='" & SourceList.List(CurrentSource) & "'"
i = DestRst.RecordCount
If i > 0 Then
DestRst.MoveFirst
For j = 1 To i
DestRst.Delete
DestRst.MoveNext
Next
End If
If SourceList.Selected(CurrentSource) Then
SourceRst.Filter = "Class='" & SourceList.List(CurrentSource) & "'"
Select Case SourceRst![dotype]
Case 0
If SourceRst![DisplayType] = "0" Then
j = 0
For i = 0 To SqlList.ListCount - 1
If SqlList.Selected(i) Then
DestRst.AddNew
DestRst![DoClass] = SourceRst![Class]
DestRst![dotype] = SourceRst![DoWhy]
DestRst![DisValue] = SqlList.List(i)
DestRst.Update
j = j + 1
End If
Next
If j = 0 Then
SourceList.Selected(CurrentSource) = False
End If
Else
j = 0
For i = 0 To DoubleList.ListCount - 1
DestRst.AddNew
DestRst![DoClass] = SourceRst![Class]
DestRst![dotype] = SourceRst![DoWhy]
DestRst![DisValue] = DoubleList.List(i)
DestRst.Update
j = j + 1
Next
If j = 0 Then
SourceList.Selected(CurrentSource) = False
End If
End If
Case 1, 2
j = 0
For i = 0 To SqlList.ListCount - 1
If SqlList.Selected(i) Then
DestRst.AddNew
DestRst![DoClass] = SourceRst![Class]
DestRst![dotype] = SourceRst![DoWhy]
DestRst![DisValue] = SqlList.List(i)
DestRst.Update
j = j + 1
End If
Next
If j = 0 Then
SourceList.Selected(CurrentSource) = False
End If
Case 3
DestRst.AddNew
DestRst![DoClass] = SourceRst![Class]
DestRst![dotype] = "="
DestRst![DisValue] = Me.DateBegin.Value
DestRst.Update
Case 4
DestRst.AddNew
DestRst![DoClass] = SourceRst![Class]
DestRst![dotype] = "Between"
DestRst![DisValue] = Me.DateBegin.Value & "|" & Me.DateEnd.Value & "|"
DestRst.Update
Case 5
DestRst.AddNew
DestRst![DoClass] = SourceRst![Class]
DestRst![dotype] = "="
DestRst![DisValue] = Me.WriteValue.Text
DestRst.Update
End Select
End If
End If
CurrentSource = SourceList.ListIndex
PrintDestBox
PrintSqlBox
End Sub
Private Sub PrintDestBox()
Dim i As Long, j As Long, k As Long, s As String, l As String
DestList.Clear
DestRst.Filter = ""
i = DestRst.RecordCount
If i > 0 Then
DestRst.MoveFirst
s = ""
For j = 1 To i
Select Case DestRst![dotype]
Case "="
If s = DestRst![DoClass] Then
l = l & " 及 " & "<" & DestRst![DisValue] & ">"
Else
If l = "" Then
Else
DestList.AddItem l
End If
l = DestRst![DoClass] & " 等于 " & "<" & DestRst![DisValue] & ">"
s = DestRst![DoClass]
End If
If j = i Then
DestList.AddItem l
End If
Case "Between"
For k = 1 To Len(DestRst![DisValue])
If Mid(DestRst![DisValue], k, 1) = "|" Then
DestList.AddItem DestRst![DoClass] & " 在 " & "<" & Left(DestRst![DisValue], k - 1) & "> 与 <" & Mid(DestRst![DisValue], k + 1, Len(DestRst![DisValue]) - k - 1) & "> 之间"
Exit For
End If
Next
Case Else
If s = DestRst![DoClass] Then
l = l & " 及 " & "<" & DestRst![DisValue] & ">"
Else
If l = "" Then
Else
DestList.AddItem l
End If
l = DestRst![DoClass] & " 等于 " & "<" & DestRst![DisValue] & ">"
s = DestRst![DoClass]
End If
If j = i Then
DestList.AddItem l
End If
End Select
DestRst.MoveNext
Next
End If
End Sub
Private Sub SourceList_ItemCheck(Item As Integer)
Dim i As Long, j As Long, k As Long, s As String
If SourceList.Selected(Item) Then
SourceRst.Filter = "Class='" & SourceList.List(Item) & "'"
s = Trim(SourceRst![groupid])
SourceRst.Filter = "Class<>'" & SourceList.List(Item) & "' and GroupId=" & s
i = SourceRst.RecordCount
If i > 0 Then
SourceRst.MoveFirst
For j = 1 To i
Debug.Print SourceRst![Class]
For k = 0 To SourceList.ListCount - 1
'MsgBox SourceList.Selected(k)
If SourceList.List(k) = SourceRst![Class] And SourceList.Selected(k) Then
SourceList.Selected(Item) = False
MsgBox "{" & SourceList.List(k) & "}与{" & SourceList.List(Item) & "}只能选择一种!!!"
End If
Next
Next
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -