📄 frmyh_djwhselect.frm
字号:
Caption = "至"
Height = 180
Left = 2235
TabIndex = 13
Top = 510
Width = 180
End
End
Attribute VB_Name = "frmYH_DjwhSelect"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim CSubject As clsSubject
Public Ok As Boolean
Private Sub cboSubject_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then SendKeys "{tab}"
End Sub
Private Sub ChkNotRecord_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then SendKeys "{tab}"
End Sub
Private Sub Form_Initialize()
Set CSubject = New clsSubject
Ok = False
End Sub
Private Sub cmdCancel_Click()
Ok = False
Me.Hide
End Sub
Private Sub cmdHelp_Click()
SendKeys "F1"
End Sub
Private Sub cmdOk_Click()
If cboSubject.text = "" Then
MsgBox "请选择用于查询的科目!", vbInformation
cboSubject.SetFocus
Else
Ok = True
Me.Hide
End If
End Sub
Private Sub form_load()
Dim rSt As ADODB.Recordset
Dim rstTemp As ADODB.Recordset
Dim sSQL As String
Dim i As Long
'年份设计为不允许修改
Set rstTemp = New ADODB.Recordset
rstTemp.CursorLocation = adUseClient
sSQL = "SELECT * FROM tSYS_SubSysUsed WHERE AccountID = '" & glo.sAccountID & _
"' AND SubSysID = '" & gloSys.sSubSysId & "'"
rstTemp.Open sSQL, gloSys.cnnSYS, adOpenStatic, adLockReadOnly
With rstTemp
If .RecordCount > 0 Then
If Val(glo.sOperateYear) > Val(.Fields("ModiYear").value) Then
updMonthFrom.Min = 1
updMonthTo.Min = 1
Else
updMonthFrom.Min = IIf(Val(glo.sOperateYear) = Val(.Fields("BeginYear").value), .Fields("BeginMonth").value, 1)
updMonthTo.Min = updMonthFrom.Min
End If
End If
End With
'取当前登录时间为默认的年、月、日
txtYear.text = Year(glo.sOperateDate)
updMonthFrom.value = Month(glo.sOperateDate)
updMonthTo.value = Month(glo.sOperateDate)
updDayFrom.value = Day(glo.sOperateDate)
updDayTo.value = Day(glo.sOperateDate)
'装入所有日记账科目
Set rSt = New ADODB.Recordset
rSt.CursorLocation = adUseClient
With rSt
.Open "select kmdm,kmmc from tZW_km" & glo.sOperateYear & _
" where IsYhz=-1 order by kmdm", _
glo.cnnMain, adOpenStatic, adLockReadOnly
If .RecordCount = 0 Then
MsgBox "还没有任何银行账科目!", vbInformation
Else
cboSubject.Clear
Do Until .EOF
cboSubject.AddItem Trim$("" & .Fields("kmdm").value) & _
"=" & Trim$("" & .Fields("kmmc").value)
.MoveNext
Loop
End If
.Close
End With
End Sub
Private Sub txtDayFrom_GotFocus()
txtDayFrom.SelStart = 0
txtDayFrom.SelLength = Len(txtDayFrom.text)
End Sub
Private Sub txtDayFrom_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
Else
KeyAscii = IntegerEnabled(KeyAscii)
End If
End Sub
Private Sub txtDayFrom_LostFocus()
If txtMonthFrom.text = txtMonthTo.text Then
If txtDayFrom.text > txtDayTo.text Then
txtDayTo.text = txtDayFrom.text
End If
End If
End Sub
Private Sub txtDayFrom_Validate(Cancel As Boolean)
If Val(txtDayFrom.text) < 1 Or Val(txtDayFrom.text) > 31 Then
MsgBox "日期值超出范围!", vbExclamation
Cancel = True
ElseIf Not IsDate(txtYear.text & "-" & Format(txtMonthFrom.text, "00") & _
"-" & Format(txtDayFrom.text, "00")) Then
MsgBox "该日期不存在!", vbInformation
Cancel = True
End If
End Sub
Private Sub txtDayTo_GotFocus()
txtDayTo.SelStart = 0
txtDayTo.SelLength = Len(txtDayTo.text)
End Sub
Private Sub txtDayTo_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
Else
KeyAscii = IntegerEnabled(KeyAscii)
End If
End Sub
Private Sub txtDayTo_LostFocus()
If txtMonthFrom.text = txtMonthTo.text Then
If txtDayTo.text < txtDayFrom.text Then
txtDayFrom.text = txtDayTo.text
End If
End If
End Sub
Private Sub txtDayTo_Validate(Cancel As Boolean)
If Val(txtDayTo.text) < 1 Or Val(txtDayTo.text) > 31 Then
MsgBox "日期值超出范围!", vbExclamation
Cancel = True
Exit Sub
End If
If Not IsDate(txtYear.text & "-" & Format(txtMonthTo.text, "00") & _
"-" & Format(txtDayTo.text, "00")) Then
MsgBox "该日期不存在!", vbInformation
Cancel = True
Exit Sub
End If
End Sub
Private Sub txtMonthFrom_GotFocus()
txtMonthFrom.SelStart = 0
txtMonthFrom.SelLength = Len(txtMonthFrom.text)
End Sub
Private Sub txtMonthFrom_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
Else
KeyAscii = IntegerEnabled(KeyAscii)
End If
End Sub
Private Sub txtMonthFrom_LostFocus()
If Val(txtMonthFrom.text) > Val(txtMonthTo.text) Then
txtMonthTo.text = txtMonthFrom.text
End If
End Sub
Private Sub txtMonthFrom_Validate(Cancel As Boolean)
If Val(txtMonthFrom.text) < 1 Or Val(txtMonthFrom.text) > 12 Then
MsgBox "请输入一个合法的月份值!", vbExclamation
Cancel = True
txtMonthFrom.SelStart = 0
txtMonthFrom.SelLength = Len(txtMonthFrom.text)
End If
End Sub
Private Sub txtMonthTo_GotFocus()
txtMonthTo.SelStart = 0
txtMonthTo.SelLength = Len(txtMonthTo.text)
End Sub
Private Sub txtMonthTo_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
Else
KeyAscii = IntegerEnabled(KeyAscii)
End If
End Sub
Private Sub txtMonthTo_LostFocus()
If Val(txtMonthTo.text) < Val(txtMonthFrom.text) Then
txtMonthFrom.text = txtMonthTo.text
End If
End Sub
Private Sub txtMonthTo_Validate(Cancel As Boolean)
If Val(txtMonthTo.text) < 1 Or Val(txtMonthTo.text) > 12 Then
MsgBox "请输入一个合法的月份值!", vbExclamation
Cancel = True
txtMonthTo.SelStart = 0
txtMonthTo.SelLength = Len(txtMonthTo.text)
End If
End Sub
Private Sub txtYear_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
Else
KeyAscii = IntegerEnabled(KeyAscii)
End If
End Sub
Private Sub updDayFrom_Change()
If txtMonthFrom.text = txtMonthTo.text Then
updDayTo.Min = txtDayFrom.text
End If
End Sub
Private Sub updMonthFrom_Change()
updMonthTo.Min = txtMonthFrom.text
If txtMonthFrom.text = 12 Then
updDayFrom.Max = 31
Else
updDayFrom.Max = DateDiff("d", glo.sOperateYear & "-" & Format(txtMonthFrom.text, "00") & "-01", _
glo.sOperateYear & "-" & Format(txtMonthFrom.text + 1, "00") & " -01")
End If
If Val(txtDayFrom.text) > updDayFrom.Max Then
txtDayFrom.text = updDayFrom.Max
End If
End Sub
Private Sub updMonthTo_Change()
If txtMonthTo.text = 12 Then
updDayTo.Max = 31
Else
updDayTo.Max = DateDiff("d", glo.sOperateYear & "-" & Format(txtMonthTo.text, "00") & "-01", _
glo.sOperateYear & "-" & Format(txtMonthTo.text + 1, "00") & "-01")
End If
If Val(txtDayTo.text) > updDayTo.Max Then
txtDayTo.text = updDayTo.Max
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -