📄 form_month.frm
字号:
Private Sub Check3_Click()
If Me.Check3.Value = 1 Then
Me.Check2.Value = 0
Me.Check4.Value = 0
End If
Me.Combo3.Text = ""
Me.Combo4.Text = ""
Me.Text1.Text = ""
Me.Text2.Text = ""
End Sub
Private Sub Check4_Click()
If Me.Check4.Value = 1 Then
Me.Check2.Value = 0
Me.Check3.Value = 0
End If
Me.Combo3.Text = ""
Me.Combo4.Text = ""
Me.Text1.Text = ""
Me.Text2.Text = ""
End Sub
Private Sub Check5_Click()
If Me.Check5.Value = 1 Then
Me.Check1.Value = 0
Me.Check6.Value = 0
End If
Me.Combo7.Text = ""
Me.Combo8.Text = ""
Me.Text3.Text = ""
Me.Text4.Text = ""
End Sub
Private Sub Check6_Click()
If Me.Check6.Value = 1 Then
Me.Check5.Value = 0
Me.Check1.Value = 0
End If
Me.Combo7.Text = ""
Me.Combo8.Text = ""
Me.Text3.Text = ""
Me.Text4.Text = ""
End Sub
Private Sub Command1_Click() '查询选择内容
Dim sqlstr As String
Dim rsdb As New ADODB.Recordset
Dim num As Integer
'On Error Resume Next
If Me.Check2.Value = 1 Then '按照人员查询
'查找对应人员的编号
rsdb.Open "select * from Family where FamilyName=" & "'" & _
Me.Combo3.Text & "'", RemoteCnn, adOpenStatic, adLockReadOnly, -1
If rsdb.RecordCount > 0 Then
If Not rsdb.EOF Then rsdb.MoveFirst
num = Val(rsdb.Fields("FamilyID").Value)
End If
rsdb.Close
'进行查询
Adodc_Month.RecordSource = "select DailyIncomeID as 编号," & _
"DailyIncomeDate as 收入日期," & _
"DailyIncomeName as 收入人员," & _
"DailyIncomeType as 收入来源," & _
"DailyIncomeNum as 收入金额," & _
"DailyIncomeBZ as 备注 " & _
"from DailyIncome where DailyIncomeDate " & _
"between " & "'" & data_begin & "'" & " and " & "'" & _
data_end & "' and DailyIncomeName=" & num
'显示更新
Me.Adodc_Month.Refresh
MsgBox "查询成功!"
ElseIf Me.Check3.Value = 1 Then '按照收入来源查询
Adodc_Month.RecordSource = "select DailyIncomeID as 编号," & _
"DailyIncomeDate as 收入日期," & _
"DailyIncomeName as 收入人员," & _
"DailyIncomeType as 收入来源," & _
"DailyIncomeNum as 收入金额," & _
"DailyIncomeBZ as 备注 " & _
"from DailyIncome where DailyIncomeDate " & _
"between " & "'" & data_begin & "'" & " and " & "'" & _
data_end & "' and DailyIncomeType=" & Val(Me.Combo4.Text)
'显示更新
Me.Adodc_Month.Refresh
MsgBox "查询成功!"
ElseIf Me.Check4.Value = 1 Then '按照金额查询
If Not IsNumeric(Me.Text1.Text) Then
MsgBox "必须是数字"
Exit Sub
End If
If Not IsNumeric(Me.Text2.Text) Then
MsgBox "必须是数字"
Exit Sub
End If
Adodc_Month.RecordSource = "select DailyIncomeID as 编号," & _
"DailyIncomeDate as 收入日期," & _
"DailyIncomeName as 收入人员," & _
"DailyIncomeType as 收入来源," & _
"DailyIncomeNum as 收入金额," & _
"DailyIncomeBZ as 备注 " & _
"from DailyIncome where DailyIncomeDate " & _
"between " & "'" & data_begin & "'" & " and " & "'" & _
data_end & "' and DailyIncomeNum between " & _
Val(Me.Text1.Text) & "and " & Val(Me.Text2.Text)
'显示更新
Me.Adodc_Month.Refresh
MsgBox "查询成功!"
End If
End Sub
Private Sub Command2_Click() '更改月份
Dim data
If Me.Combo1.Text = "" Or Me.Combo2.Text = "" Then
MsgBox "不能空白"
Exit Sub
End If
'设定日期范围
data = Val(Me.Combo1.Text) & "-" & Val(Me.Combo2.Text)
data_begin = DateValue(data & "-1")
data = Val(Me.Combo1.Text) & "-" & Val(Me.Combo2.Text) + 1
If Val(Me.Combo2.Text) = 12 Then
data = (Val(Me.Combo1.Text) + 1) & "-1"
End If
data_end = DateValue(data & "-1")
'更改显示年月
Me.Label1.Caption = Val(Me.Combo1.Text) & "年" & Val(Me.Combo2.Text) & "月"
'更新表格内容
Adodc_Month.RecordSource = "select DailyIncomeID as 编号," & _
"DailyIncomeDate as 收入日期," & _
"DailyIncomeName as 收入人员," & _
"DailyIncomeType as 收入来源," & _
"DailyIncomeNum as 收入金额," & _
"DailyIncomeBZ as 备注 " & _
"from DailyIncome where DailyIncomeDate between " & _
"'" & data_begin & "'" & " and " & "'" & data_end & "'"
Adodc_Month.Refresh
End Sub
Private Sub Command3_Click() '更改月份
Dim data
If Me.Combo5.Text = "" Or Me.Combo6.Text = "" Then
MsgBox "不能空白"
Exit Sub
End If
'设定日期范围
data = Val(Me.Combo5.Text) & "-" & Val(Me.Combo6.Text)
data_begin1 = DateValue(data & "-1")
data = Val(Me.Combo5.Text) & "-" & Val(Me.Combo6.Text) + 1
If Val(Me.Combo6.Text) = 12 Then
data = (Val(Me.Combo5.Text) + 1) & "-1"
End If
data_end1 = DateValue(data & "-1")
'更改显示年月
Me.Label2.Caption = Val(Me.Combo5.Text) & "年" & Val(Me.Combo6.Text) & "月"
'更新表格内容
Adodc_Month1.RecordSource = "select DailyOutputID as 编号," & _
"DailyOutputDate as 支出日期," & _
"DailyOutputName as 支出人员," & _
"DailyOutputType as 支出类型," & _
"DailyOutputNum as 支出金额," & _
"DailyOutputBZ as 备注 " & _
"from DailyOutput where DailyOutputDate between " & "'" & data_begin1 & "'" & " and " & "'" & data_end1 & "'"
Adodc_Month1.Refresh
End Sub
Private Sub Command4_Click() '查询选择内容
Dim sqlstr As String
Dim rsdb As New ADODB.Recordset
Dim num As Integer
If Me.Check1.Value = 1 Then '按照人员查询
'查找对应人员的编号
rsdb.Open "select * from Family where FamilyName=" & "'" & Me.Combo7.Text & "'", RemoteCnn, adOpenStatic, adLockReadOnly, -1
If rsdb.RecordCount > 0 Then
If Not rsdb.EOF Then rsdb.MoveFirst
num = Val(rsdb.Fields("FamilyID").Value)
End If
rsdb.Close
'进行查询
Adodc_Month1.RecordSource = "select DailyOutputID as 编号," & _
"DailyOutputDate as 支出日期," & _
"DailyOutputName as 支出人员," & _
"DailyOutputType as 支出类型," & _
"DailyOutputNum as 支出金额," & _
"DailyOutputBZ as 备注 " & _
"from DailyOutput where DailyOutputDate between " & "'" & data_begin1 & "'" & " and " & "'" & data_end1 & "' and DailyOutputName=" & num
'显示更新
Me.Adodc_Month1.Refresh
MsgBox "查询成功!"
ElseIf Me.Check5.Value = 1 Then '按照支出类型查询
Adodc_Month1.RecordSource = "select DailyOutputID as 编号," & _
"DailyOutputDate as 支出日期," & _
"DailyOutputName as 支出人员," & _
"DailyOutputType as 支出类型," & _
"DailyOutputNum as 支出金额," & _
"DailyOutputBZ as 备注 " & _
"from DailyOutput where DailyOutputDate between " & "'" & data_begin1 & "'" & " and " & "'" & data_end1 & "' and DailyOutputType=" & Val(Me.Combo8.Text)
Me.Adodc_Month1.Refresh
MsgBox "查询成功!"
ElseIf Me.Check6.Value = 1 Then '按照金额查询
If Not IsNumeric(Me.Text3.Text) Then
MsgBox "必须是数字"
Exit Sub
End If
If Not IsNumeric(Me.Text4.Text) Then
MsgBox "必须是数字"
Exit Sub
End If
'进行查询
Adodc_Month1.RecordSource = "select DailyOutputID as 编号," & _
"DailyOutputDate as 支出日期," & _
"DailyOutputName as 支出人员," & _
"DailyOutputType as 支出类型," & _
"DailyOutputNum as 支出金额," & _
"DailyOutputBZ as 备注 " & _
"from DailyOutput where DailyOutputDate between " & "'" & data_begin1 & "'" & " and " & "'" & data_end1 & "' and DailyOutputNum between " & Val(Me.Text3.Text) & "and " & Val(Me.Text4.Text)
'显示更新
Me.Adodc_Month1.Refresh
MsgBox "查询成功!"
End If
End Sub
Private Sub Command5_Click()
Unload Me
End Sub
Private Sub Command6_Click()
Unload Me
End Sub
Private Sub Form_Load() '窗体装载
Dim rsdb As New ADODB.Recordset
Dim data1
'On Error Resume Next
'填充人员框
rsdb.Open "select * from Family", RemoteCnn, adOpenStatic, adLockReadOnly, -1
If rsdb.RecordCount > 0 Then
If Not rsdb.BOF Then rsdb.MoveFirst
For i = 1 To rsdb.RecordCount
Me.Combo3.AddItem rsdb.Fields("FamilyName").Value
Me.Combo7.AddItem rsdb.Fields("FamilyName").Value
If Not rsdb.EOF Then rsdb.MoveNext
Next i
End If
rsdb.Close
'填充收入来源框
rsdb.Open "select * from IncomeType", RemoteCnn, adOpenStatic, adLockReadOnly, -1
If rsdb.RecordCount > 0 Then
If Not rsdb.BOF Then rsdb.MoveFirst
For i = 1 To rsdb.RecordCount
Me.Combo4.AddItem rsdb.Fields("IncomeTypeID").Value & ":" & _
rsdb.Fields("IncomeTypeType").Value
If Not rsdb.EOF Then rsdb.MoveNext
Next i
End If
rsdb.Close
'填充支出类型框
rsdb.Open "select * from OutputType", RemoteCnn, adOpenStatic, adLockReadOnly, -1
If rsdb.RecordCount > 0 Then
If Not rsdb.BOF Then rsdb.MoveFirst
For i = 1 To rsdb.RecordCount
Me.Combo8.AddItem rsdb.Fields("OutputTypeID").Value & ":" & _
rsdb.Fields("OutputTypeType").Value
If Not rsdb.EOF Then rsdb.MoveNext
Next i
End If
rsdb.Close
'显示当前年月
Me.Label1.Caption = Year(Now) & "年" & Month(Now) & "月"
Me.Label2.Caption = Year(Now) & "年" & Month(Now) & "月"
'设定时间范围
data1 = Year(Now) & "-" & Month(Now)
data_begin = DateValue(data1 & "-1")
data_begin1 = DateValue(data1 & "-1")
data1 = Year(Now) & "-" & Month(Now) + 1
If Val(Month(Now)) = 12 Then
data1 = Year(Now) + 1 & "-1"
End If
data_end = DateValue(data1 & "-1")
data_end1 = DateValue(data1 & "-1")
'打开日常收入表并填充表格
Me.Adodc_Month.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=" & _
"False;User ID=" & UID & ";pwd=" & PWD & ";Data Source=" & MyDSN
Adodc_Month.RecordSource = "select DailyIncomeID as 编号," & _
"DailyIncomeDate as 收入日期," & _
"DailyIncomeName as 收入人员," & _
"DailyIncomeType as 收入来源," & _
"DailyIncomeNum as 收入金额," & _
"DailyIncomeBZ as 备注 " & _
"from DailyIncome where DailyIncomeDate between " & _
"'" & data_begin & "'" & " and " & "'" & data_end & "'"
Adodc_Month.Refresh
'打开日常支出表并填充表格
Me.Adodc_Month1.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=" & _
"False;User ID=" & UID & ";pwd=" & PWD & ";Data Source=" & MyDSN
Adodc_Month1.RecordSource = "select DailyOutputID as 编号," & _
"DailyOutputDate as 支出日期," & _
"DailyOutputName as 支出人员," & _
"DailyOutputType as 支出类型," & _
"DailyOutputNum as 支出金额," & _
"DailyOutputBZ as 备注 " & _
"from DailyOutput where DailyOutputDate between " & _
"'" & data_begin1 & "'" & " and " & "'" & data_end1 & "'"
Adodc_Month1.Refresh
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -