(前几天写的)
就为了一个事件写了那么多的IF,天啊,再这样发展下去,不堪设想;不过应该没什么发展了吧(其实有些IF可以看起来可以简化,这是自己故意写的)
With VSFlexGrid1
For currentRow = 1 To .Rows - 1
Set rsSign = New Recordset
rsSign.Open "Select * from 培训报名表 where 合同编号='" & .TextMatrix(currentRow, 1) & "'", cnSign, adOpenStatic, adLockOptimistic
'Do While Not rsSign.EOF
For i = 1 To 56
Ti = "课时" & i
'判断是否是空的
If IsNull(rsSign.Fields(Ti).Value) Then '空的就可以写
'判断是否已经有了这个日期
If PreSignDate = SystemDay Then
'有该日期警告
If MsgBox(rsSign!学员中文名 & " 在 " & SystemDay & txtSign(0).Text & " 的记录已有,是否继续输入?", vbOKCancel, "输入警告") = vbOK Then
'重复了但用户选择继续输入
If .TextMatrix(currentRow, 5) = "-1" Then
rsSign.Fields(Ti).Value = SystemDay & "Y"
rsSign.Update
Exit For '输入已到结束此次循环
Else
rsSign.Fields(Ti).Value = SystemDay & "N"
rsSign.Update
Exit For '输入未到结束此次循环
End If
Else
Exit For '重复了但用户选择不输入,结束此次循环
End If
Else
'没有该日期不警告
If .TextMatrix(currentRow, 5) = "-1" Then
rsSign.Fields(Ti).Value = SystemDay & "Y"
rsSign.Update
Exit For '输入已到结束此次循环
Else
rsSign.Fields(Ti).Value = SystemDay & "N"
rsSign.Update
Exit For '输入未到结束此次循环
End If
End If
Else
'不为空则记录这个值
PreSignDate = Left(rsSign.Fields(Ti).Value, Len(rsSign.Fields(Ti).Value) - 1)
End If
Next i
rsSign.MoveNext
' Loop
rsSign.Close
PreSignDate = ""
Next
End With