📄 frmadd.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmAdd
BackColor = &H80000018&
Caption = "会计科目_增加"
ClientHeight = 5220
ClientLeft = 60
ClientTop = 345
ClientWidth = 7170
Icon = "frmAdd.frx":0000
LinkTopic = "Form1"
ScaleHeight = 5220
ScaleWidth = 7170
StartUpPosition = 3 '窗口缺省
Begin MSAdodcLib.Adodc Adodc1
Height = 495
Left = 240
Top = 3840
Visible = 0 'False
Width = 1935
_ExtentX = 3413
_ExtentY = 873
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=AISKM.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=AISKM.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.CommandButton Command2
Caption = "返回"
Height = 375
Left = 3840
TabIndex = 10
Top = 4440
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "增加"
Height = 375
Left = 2280
TabIndex = 9
Top = 4440
Width = 1215
End
Begin VB.Frame Frame1
BackColor = &H80000018&
Caption = "余额方向"
Height = 1095
Left = 2160
TabIndex = 6
Top = 3000
Width = 2655
Begin VB.OptionButton Option1
BackColor = &H80000018&
Caption = "贷"
Height = 255
Index = 1
Left = 840
TabIndex = 11
Top = 600
Width = 735
End
Begin VB.OptionButton Option1
BackColor = &H80000018&
Caption = "借"
Height = 255
Index = 0
Left = 840
TabIndex = 7
Top = 240
Width = 735
End
End
Begin VB.ComboBox Combo1
Height = 300
Left = 3360
TabIndex = 5
Text = "请选择类别"
Top = 2520
Width = 1455
End
Begin VB.TextBox Text2
Height = 270
Left = 3360
TabIndex = 1
Top = 1680
Width = 1455
End
Begin VB.TextBox Text1
Height = 270
Left = 3360
TabIndex = 0
Top = 960
Width = 1455
End
Begin VB.Label Label4
BackColor = &H80000018&
Caption = "*科目级长3-2-2"
Height = 255
Left = 4920
TabIndex = 8
Top = 960
Width = 1335
End
Begin VB.Label Label3
BackColor = &H80000018&
Caption = "科目类别"
Height = 255
Left = 2040
TabIndex = 4
Top = 2520
Width = 1215
End
Begin VB.Label Label2
BackColor = &H80000018&
Caption = "科目名称"
Height = 375
Left = 2040
TabIndex = 3
Top = 1680
Width = 1215
End
Begin VB.Label Label1
BackColor = &H80000018&
Caption = "科目代码"
Height = 375
Left = 2160
TabIndex = 2
Top = 960
Width = 1095
End
End
Attribute VB_Name = "frmAdd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'验证科目和代码一致性
Private Sub Combo1_Click()
Dim strClass As String
strClass = Left(Text1.Text, 1)
If Combo1.Text = "资产" And strClass <> "1" Then
MsgBox "请确认科目代码与科目类别一致"
Combo1.SetFocus
ElseIf Combo1.Text = "负债" And strClass <> "2" Then
MsgBox "请确认科目代码与科目类别一致"
Combo1.SetFocus
ElseIf Combo1.Text = "权益" And strClass <> "3" Then
MsgBox "请确认科目代码与科目类别一致"
Combo1.SetFocus
ElseIf Combo1.Text = "成本" And strClass <> "4" Then
MsgBox "请确认科目代码与科目类别一致"
Combo1.SetFocus
ElseIf Combo1.Text = "损益" And strClass <> "5" Then
MsgBox "请确认科目代码与科目类别一致"
Combo1.SetFocus
End If
'自动关联余额方向
If Combo1.Text = "资产" Or Combo1.Text = "成本" Then
Option1(0).Value = True
Option1(1).Value = False
Else
Option1(0).Value = False
Option1(1).Value = True
End If
End Sub
'验证输入非空
Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox "请输入科目代码"
Text1.SetFocus
ElseIf Text2.Text = "" Then
MsgBox "请输入科目名称"
Text2.SetFocus
ElseIf Combo1.Text = "" Then
MsgBox "请输入科目类别"
ElseIf Option1(0).Value = False And Option1(1).Value = False Then
MsgBox "请输入借贷方向"
ElseIf Len(Text1.Text) <> 3 And Len(Text1.Text) <> 5 And Len(Text1.Text) <> 7 Then
MsgBox "请输入正确的科目代码"
Else
'验证科目代号与科目类型是否一致
Dim strClass As String
strClass = Left(Text1.Text, 1)
If Combo1.Text = "资产" And strClass <> "1" Then
MsgBox "请确认科目代码与科目类别一致"
ElseIf Combo1.Text = "负债" And strClass <> "2" Then
MsgBox "请确认科目代码与科目类别一致"
ElseIf Combo1.Text = "权益" And strClass <> "3" Then
MsgBox "请确认科目代码与科目类别一致"
ElseIf Combo1.Text = "成本" And strClass <> "4" Then
MsgBox "请确认科目代码与科目类别一致"
ElseIf Combo1.Text = "损益" And strClass <> "5" Then
MsgBox "请确认科目代码与科目类别一致"
Else
'验证一级、二级科目是否存在
' Adodc1.Refresh
Dim strFirst As String
strFirst = Left(Text1.Text, 3)
Adodc1.RecordSource = "select 科目代码 from kmzd where 科目代码='" + strFirst + "'"
Adodc1.Refresh
If Len(Text1.Text) = 3 Then
Call InsertSubject
ElseIf Len(Text1.Text) > 3 And Adodc1.Recordset.RecordCount < 1 Then
MsgBox "请先输入一级科目代码"
Else
Call InsertSubject
End If
End If
End If
End Sub
'插入科目函数
Sub InsertSubject()
Adodc1.RecordSource = "select * from kmzd where 科目代码='" + Text1.Text + "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount >= 1 Then
MsgBox "此科目代码已经添加"
Else
Adodc1.RecordSource = "select * from kmzd"
Adodc1.Refresh
Adodc1.Recordset.addnew
Adodc1.Recordset.Fields(0) = Text1.Text
Adodc1.Recordset.Fields(1) = Text2.Text
Adodc1.Recordset.Fields(2) = Combo1.Text
If Option1(0).Value = True Then
Adodc1.Recordset.Fields(3) = Option1(0).Caption
ElseIf Option1(1).Value = True Then
Adodc1.Recordset.Fields(3) = Option1(1).Caption
End If
Adodc1.Recordset.Update
MsgBox "科目增加成功"
frmQuerry.Adodc1.Refresh
Text1.Text = ""
Text2.Text = ""
Combo1.Text = 请选择类别
Combo1.Refresh
Option1(0).Value = False
Option1(1).Value = False
Text1.SetFocus
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
'更改余额方向的控制
Private Sub Option1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim Str As Integer
Str = MsgBox("你确定要更改余额方向吗?它是和科目类别相关的", vbYesNo + vbQuestion, "信息提示")
If Str = vbYes And Option1(1).Value = True Then
Option1(0) = Not Option1(0).Value
ElseIf Str = vbYes And Option1(0).Value = True Then
Option1(1) = Not Option1(1).Value
End If
End Sub
'科目代号输入控制
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text2.SetFocus
ElseIf KeyAscii <> 8 And KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
MsgBox "请输入数字"
End If
End Sub
Private Sub Text1_LostFocus()
If Len(Text1.Text) = 0 Then
ElseIf Len(Text1.Text) <> 3 And Len(Text1.Text) <> 5 And Len(Text1.Text) <> 7 Then
MsgBox "请输入正确的科目代码"
Text1.SetFocus
End If
End Sub
'科目名称输入控制
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii > 48 And KeyAscii < 57 Then
KeyAscii = 0
MsgBox "请不要输入数字"
End If
If KeyAscii = 13 Then
Combo1.SetFocus
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -