龙空技术网

学校快递管理系统 Access数据库系统 VBA代码分享

凌霄百科 406

前言:

目前大家对“校园导航系统课程设计c语言代码怎么写”大约比较注意,兄弟们都想要知道一些“校园导航系统课程设计c语言代码怎么写”的相关资讯。那么小编同时在网络上网罗了一些有关“校园导航系统课程设计c语言代码怎么写””的相关知识,希望大家能喜欢,同学们一起来了解一下吧!

系统导航

Option Compare Database

Private Sub Command快递查询_Click()

DoCmd.OpenForm "快递查询", acNormal

End Sub

Private Sub Command快递费管理_Click()

DoCmd.OpenForm "快递费管理", acNormal

End Sub

Private Sub Command快递管理_Click()

DoCmd.OpenForm "快递管理", acNormal

End Sub

Private Sub Command快递添加_Click()

DoCmd.OpenForm "快递添加", acNormal

End Sub

Private Sub Command收件查询_Click()

DoCmd.OpenForm "收件查询", acNormal

End Sub

Private Sub Command收件管理_Click()

DoCmd.OpenForm "收件管理", acNormal

End Sub

Private Sub Command收件添加_Click()

DoCmd.OpenForm "收件添加", acNormal

End Sub

Private Sub Command退出系统_Click()

If MsgBox("是否退出该系统?", vbYesNo) = vbYes Then

Application.Quit acQuitSaveAll

End If

End Sub

Private Sub Command学生管理_Click()

DoCmd.OpenForm "学生管理", acNormal

End Sub

Private Sub Command寄件查询_Click()

DoCmd.OpenForm "寄件查询", acNormal

End Sub

Private Sub Command寄件管理_Click()

DoCmd.OpenForm "寄件管理", acNormal

End Sub

Private Sub Command寄件添加_Click()

DoCmd.OpenForm "寄件添加", acNormal

End Sub

寄件查询

组合框,文本框,按钮,子窗体

Private Sub Command报表_Click()

If Me.数据表子窗体.Form.FilterOn = False Then

DoCmd.OpenReport "寄件报表", acViewReport

Else

DoCmd.OpenReport "寄件报表", acViewReport, , Me.数据表子窗体.Form.Filter

End If

End Sub

Private Sub Command查询_Click()

If Me.查询类型 <> "" And Me.查询内容 <> "" Then

Me.数据表子窗体.Form.Filter = Me.查询类型 & " like '*" & Me.查询内容 & "*'"

Me.数据表子窗体.Form.FilterOn = True

Else

Me.数据表子窗体.Form.FilterOn = False

End If

End Sub

Private Sub Command全部_Click()

Me.数据表子窗体.Form.FilterOn = False

End Sub

寄件查询数据表

数据表形式窗体

Private Sub 寄件单号_DblClick(Cancel As Integer)

DoCmd.OpenForm "寄件管理", acNormal, , "寄件单号='" & Me.寄件单号 & "'"

End Sub

寄件管理

文本框,组合框,按钮,绑定记录窗体

Private Sub Command更新_Click()

If 寄件单号.Value <> "" And 快递公司.Value <> "" And 收件地点.Value <> "" And 收件人.Value <> "" And 收件地址.Value <> "" And 收件人联系方式.Value <> "" And 寄件人.Value <> "" And 寄件地址.Value <> "" And 寄件人联系方式.Value <> "" _

And 快递单价.Value <> "" And 快递费.Value <> "" And 寄件学生.Value <> "" And 寄件时间.Value <> "" Then

On Error Resume Next

DoCmd.RunCommand acCmdSaveRecord

Else

MsgBox "寄件单号,快递公司,收件地点,收件人,收件地址,收件人联系方式,寄件人,寄件地址,寄件人联系方式,快递单价,快递费,寄件学生,寄件时间不能为空"

On Error Resume Next

DoCmd.RunCommand acCmdUndo

Exit Sub

End If

If Error.Number <> 0 Then

MsgBox Error.Description

End If

End Sub

Private Sub Command删除_Click()

On Error Resume Next

DoCmd.SetWarnings (False)

If MsgBox("是否删除该寄件记录?", vbYesNo) = vbYes Then

DoCmd.RunCommand acCmdDeleteRecord

MsgBox "删除成功"

DoCmd.Close acForm, Me.Name

Else

Exit Sub

End If

If Error.Number <> 0 Then

MsgBox Error.Description

End If

End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)

If 寄件单号.Value <> "" And 快递公司.Value <> "" And 收件地点.Value <> "" And 收件人.Value <> "" And 收件地址.Value <> "" And 收件人联系方式.Value <> "" And 寄件人.Value <> "" And 寄件地址.Value <> "" And 寄件人联系方式.Value <> "" _

And 快递单价.Value <> "" And 快递费.Value <> "" And 寄件学生.Value <> "" And 寄件时间.Value <> "" Then

On Error GoTo 数据更新前提醒_Err

If (MsgBox("是否保存对记录的修改", 1, "修改记录提醒") = 1) Then

Beep

Else

DoCmd.RunCommand acCmdUndo

End If

Else

MsgBox "快寄件单号,快递公司,收件地点,收件人,收件地址,收件人联系方式,寄件人,寄件地址,寄件人联系方式,快递单价,快递费,寄件学生,寄件时间不能为空"

On Error Resume Next

DoCmd.RunCommand acCmdUndo

Exit Sub

End If

数据更新前提醒_Exit:

Exit Sub

数据更新前提醒_Err:

MsgBox Error$

Resume 数据更新前提醒_Exit

End Sub

Private Sub Form_Close()

On Error Resume Next

Forms("寄件查询").数据表子窗体.Form.Requery

End Sub

Private Sub Form_Load()

On Error Resume Next

Call 设置寄件物品(Me.寄件单号)

End Sub

Private Sub 寄件时间_DblClick(Cancel As Integer)

Me.寄件时间.Value = Now

End Sub

Private Sub 快递单价_AfterUpdate()

If Me.快递单价 <> "" And Me.快递重量 <> "" Then

Me.快递费 = CCur(Me.快递单价 * Me.快递重量)

Else

Me.快递费 = 0

End If

End Sub

Private Sub 快递单价_Change()

If Me.快递单价 <> "" And Me.快递重量 <> "" Then

Me.快递费 = CCur(Me.快递单价 * Me.快递重量)

Else

Me.快递费 = 0

End If

End Sub

Private Sub 快递重量_AfterUpdate()

If Me.快递单价 <> "" And Me.快递重量 <> "" Then

Me.快递费 = CCur(Me.快递单价 * Me.快递重量)

Else

Me.快递费 = 0

End If

End Sub

Private Sub 快递重量_Change()

If Me.快递单价 <> "" And Me.快递重量 <> "" Then

Me.快递费 = CCur(Me.快递单价 * Me.快递重量)

Else

Me.快递费 = 0

End If

End Sub

Sub 设置寄件物品(ByVal jjdh As String)

Me.快递物品.RowSource = "SELECT 快递表.物品, 快递表.物品类别, 快递表.重量 FROM 快递表 where 快递单号='" & jjdh & "'"

Me.快递物品.Requery

End Sub

寄件添加

文本框,组合框,按钮

Private Sub Command快递添加_Click()

DoCmd.OpenForm "快递添加", acNormal

End Sub

Private Sub Command清空_Click()

寄件单号.Value = ""

快递公司.Value = ""

收件地点.Value = ""

收件人.Value = ""

收件地址.Value = ""

收件人联系方式.Value = ""

寄件人.Value = ""

寄件地址.Value = ""

寄件人联系方式.Value = ""

快递单价.Value = ""

快递费.Value = ""

寄件学生.Value = ""

寄件时间.Value = ""

备注说明.Value = ""

Me.快递重量 = ""

Me.快递物品 = ""

End Sub

Private Sub Command添加_Click()

If 寄件单号 = "" Or IsNull(寄件单号) = True Then

MsgBox "寄件单号值为空!"

Exit Sub

End If

If 快递公司 = "" Or IsNull(快递公司) = True Then

MsgBox "快递公司值为空!"

Exit Sub

End If

If 收件地点 = "" Or IsNull(收件地点) = True Then

MsgBox "收件地点值为空!"

Exit Sub

End If

If 收件人 = "" Or IsNull(收件人) = True Then

MsgBox "收件人值为空!"

Exit Sub

End If

If 收件地址 = "" Or IsNull(收件地址) = True Then

MsgBox "收件地址值为空!"

Exit Sub

End If

If 收件人联系方式 = "" Or IsNull(收件人联系方式) = True Then

MsgBox "收件人联系方式值为空!"

Exit Sub

End If

If 寄件人 = "" Or IsNull(寄件人) = True Then

MsgBox "寄件人值为空!"

Exit Sub

End If

If 寄件地址 = "" Or IsNull(寄件地址) = True Then

MsgBox "寄件地址值为空!"

Exit Sub

End If

If 寄件人联系方式 = "" Or IsNull(寄件人联系方式) = True Then

MsgBox "寄件人联系方式值为空!"

Exit Sub

End If

If 快递单价 = "" Or IsNull(快递单价) = True Then

MsgBox "快递单价值为空!"

Exit Sub

End If

If 快递费 = "" Or IsNull(快递费) = True Then

MsgBox "快递费值为空!"

Exit Sub

End If

If 寄件学生 = "" Or IsNull(寄件学生) = True Then

MsgBox "寄件学生值为空!"

Exit Sub

End If

If 寄件时间 = "" Or IsNull(寄件时间) = True Then

MsgBox "寄件时间值为空!"

Exit Sub

End If

If Nz(DCount("寄件单号", "寄件表", "寄件单号='" & Me.寄件单号 & "'"), 0) > 0 Then

MsgBox "该寄件单号已存在!"

Exit Sub

End If

Dim add_rs As DAO.Recordset

Set add_rs = CurrentDb.OpenRecordset("寄件表", dbOpenTable)

With add_rs

.AddNew

!寄件单号.Value = 寄件单号.Value

!快递公司.Value = 快递公司.Value

!收件地点.Value = 收件地点.Value

!收件人.Value = 收件人.Value

!收件地址.Value = 收件地址.Value

!收件人联系方式.Value = 收件人联系方式.Value

!寄件人.Value = 寄件人.Value

!寄件地址.Value = 寄件地址.Value

!寄件人联系方式.Value = 寄件人联系方式.Value

!快递单价.Value = 快递单价.Value

!快递费.Value = 快递费.Value

!寄件学生.Value = 寄件学生.Value

!寄件时间.Value = 寄件时间.Value

!备注说明.Value = 备注说明.Value

.Update

.Close

End With

Set add_rs = Nothing

MsgBox "添加完成"

Me.Requery

End Sub

Private Sub 寄件单号_AfterUpdate()

If Me.寄件单号 <> "" Then

Me.快递重量 = Nz(DSum("重量", "快递表", "快递单号='" & Me.寄件单号 & "'"), 0)

Call 设置寄件物品(Me.寄件单号)

Else

Me.快递重量 = 0

End If

End Sub

Private Sub 寄件单号_Change()

If Me.寄件单号 <> "" Then

Me.快递重量 = Nz(DSum("重量", "快递表", "快递单号='" & Me.寄件单号 & "'"), 0)

Call 设置寄件物品(Me.寄件单号)

Else

Me.快递重量 = 0

End If

End Sub

Private Sub 寄件时间_DblClick(Cancel As Integer)

Me.寄件时间.Value = Now

End Sub

Private Sub 快递单价_AfterUpdate()

If Me.快递单价 <> "" And Me.快递重量 <> "" Then

Me.快递费 = CCur(Me.快递单价 * Me.快递重量)

Else

Me.快递费 = 0

End If

End Sub

Private Sub 快递单价_Change()

If Me.快递单价 <> "" And Me.快递重量 <> "" Then

Me.快递费 = CCur(Me.快递单价 * Me.快递重量)

Else

Me.快递费 = 0

End If

End Sub

Private Sub 快递公司_AfterUpdate()

If Me.快递公司 <> "" And Me.收件地点 <> "" Then

Me.快递单价 = Nz(DLookup("费用单价", "快递费表", "快递公司='" & Me.快递公司 & "' and 目的地='" & Me.收件地点 & "'"), 0)

Else

Me.快递单价 = 0

End If

If Me.快递单价 <> "" And Me.快递重量 <> "" Then

Me.快递费 = CCur(Me.快递单价 * Me.快递重量)

Else

Me.快递费 = 0

End If

End Sub

Private Sub 快递公司_Change()

If Me.快递公司 <> "" And Me.收件地点 <> "" Then

Me.快递单价 = Nz(DLookup("费用单价", "快递费表", "快递公司='" & Me.快递公司 & "' and 目的地='" & Me.收件地点 & "'"), 0)

Else

Me.快递单价 = 0

End If

If Me.快递单价 <> "" And Me.快递重量 <> "" Then

Me.快递费 = CCur(Me.快递单价 * Me.快递重量)

Else

Me.快递费 = 0

End If

End Sub

Private Sub 快递重量_AfterUpdate()

If Me.快递单价 <> "" And Me.快递重量 <> "" Then

Me.快递费 = CCur(Me.快递单价 * Me.快递重量)

Else

Me.快递费 = 0

End If

End Sub

Private Sub 快递重量_Change()

If Me.快递单价 <> "" And Me.快递重量 <> "" Then

Me.快递费 = CCur(Me.快递单价 * Me.快递重量)

Else

Me.快递费 = 0

End If

End Sub

Private Sub 收件地点_AfterUpdate()

If Me.快递公司 <> "" And Me.收件地点 <> "" Then

Me.快递单价 = Nz(DLookup("费用单价", "快递费表", "快递公司='" & Me.快递公司 & "' and 目的地='" & Me.收件地点 & "'"), 0)

Else

Me.快递单价 = 0

End If

If Me.快递单价 <> "" And Me.快递重量 <> "" Then

Me.快递费 = CCur(Me.快递单价 * Me.快递重量)

Else

Me.快递费 = 0

End If

End Sub

Private Sub 收件地点_Change()

If Me.快递公司 <> "" And Me.收件地点 <> "" Then

Me.快递单价 = Nz(DLookup("费用单价", "快递费表", "快递公司='" & Me.快递公司 & "' and 目的地='" & Me.收件地点 & "'"), 0)

Else

Me.快递单价 = 0

End If

If Me.快递单价 <> "" And Me.快递重量 <> "" Then

Me.快递费 = CCur(Me.快递单价 * Me.快递重量)

Else

Me.快递费 = 0

End If

End Sub

Sub 设置寄件物品(ByVal jjdh As String)

Me.快递物品.RowSource = "SELECT 快递表.物品, 快递表.物品类别, 快递表.重量 FROM 快递表 where 快递单号='" & jjdh & "'"

Me.快递物品.Requery

End Sub

快递查询

组合框,文本框,按钮,子窗体

Private Sub Command报表_Click()

If Me.数据表子窗体.Form.FilterOn = False Then

DoCmd.OpenReport "快递报表", acViewReport

Else

DoCmd.OpenReport "快递报表", acViewReport, , Me.数据表子窗体.Form.Filter

End If

End Sub

Private Sub Command查询_Click()

If Me.查询类型 <> "" And Me.查询内容 <> "" Then

Me.数据表子窗体.Form.Filter = Me.查询类型 & " like '*" & Me.查询内容 & "*'"

Me.数据表子窗体.Form.FilterOn = True

Else

Me.数据表子窗体.Form.FilterOn = False

End If

End Sub

Private Sub Command全部_Click()

Me.数据表子窗体.Form.FilterOn = False

End Sub

快递费管理

表格布局,文本框,组合框,按钮

Private Sub Command保存_Click()

DoCmd.RunCommand acCmdSave

End Sub

Private Sub Command报表_Click()

DoCmd.OpenReport "快递费标签", acViewReport

End Sub

Private Sub Command清空_Click()

快递公司添加.Value = ""

联系电话添加.Value = ""

目的地添加.Value = ""

费用单价添加.Value = ""

备注说明添加.Value = ""

End Sub

Private Sub Command添加_Click()

If 快递公司添加 = "" Or IsNull(快递公司添加) = True Then

MsgBox "快递公司值为空!"

Exit Sub

End If

If 目的地添加 = "" Or IsNull(目的地添加) = True Then

MsgBox "目的地值为空!"

Exit Sub

End If

If 费用单价添加 = "" Or IsNull(费用单价添加) = True Then

MsgBox "费用单价值为空!"

Exit Sub

End If

DoCmd.SetWarnings (False)

Dim add_sql As String

add_sql = "Insert Into 快递费表 (快递公司,联系电话,目的地,费用单价,备注说明) Values ('" & 快递公司添加 & "','" & 联系电话添加 & "','" & 目的地添加 & "', " & 费用单价添加 & " ,'" & 备注说明添加 & "')"

DoCmd.RunSQL add_sql

MsgBox "添加完成"

Me.Requery

End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)

If 快递公司.Value <> "" And 目的地.Value <> "" And 费用单价.Value <> "" Then

On Error GoTo 数据更新前提醒_Err

If (MsgBox("是否保存对记录的修改", 1, "修改记录提醒") = 1) Then

Beep

Else

DoCmd.RunCommand acCmdUndo

End If

Else

MsgBox "学号,姓名不能为空"

On Error Resume Next

DoCmd.RunCommand acCmdUndo

Exit Sub

End If

数据更新前提醒_Exit:

Exit Sub

数据更新前提醒_Err:

MsgBox Error$

Resume 数据更新前提醒_Exit

End Sub

Private Sub 快递费ID_DblClick(Cancel As Integer)

If MsgBox("是否删除该快递费记录:" & Me.快递费ID & " ?", vbYesNo) = vbYes Then

DoCmd.SetWarnings (False)

DoCmd.OpenQuery "快递费删除查询", acViewNormal

MsgBox "删除完成"

Me.Requery

End If

End Sub

快递管理

组合框,文本框,按钮,绑定记录窗体,附件

Private Sub Command更新_Click()

If 快递类型.Value <> "" And 快递单号.Value <> "" And 物品.Value <> "" And 物品类别.Value <> "" And 重量.Value <> "" Then

On Error Resume Next

DoCmd.RunCommand acCmdSaveRecord

Else

MsgBox "快递类型,快递单号,物品,物品类别,重量不能为空"

On Error Resume Next

DoCmd.RunCommand acCmdUndo

Exit Sub

End If

If Error.Number <> 0 Then

MsgBox Error.Description

End If

End Sub

Private Sub Command删除_Click()

On Error Resume Next

DoCmd.SetWarnings (False)

If MsgBox("是否删除该快递信息?", vbYesNo) = vbYes Then

DoCmd.RunCommand acCmdDeleteRecord

MsgBox "删除成功"

DoCmd.Close acForm, Me.Name

Else

Exit Sub

End If

If Error.Number <> 0 Then

MsgBox Error.Description

End If

End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)

If 快递类型.Value <> "" And 快递单号.Value <> "" And 物品.Value <> "" And 物品类别.Value <> "" And 重量.Value <> "" Then

On Error GoTo 数据更新前提醒_Err

If (MsgBox("是否保存对记录的修改", 1, "修改记录提醒") = 1) Then

Beep

Else

DoCmd.RunCommand acCmdUndo

End If

Else

MsgBox "快递类型,快递单号,物品,物品类别,重量不能为空"

On Error Resume Next

DoCmd.RunCommand acCmdUndo

Exit Sub

End If

数据更新前提醒_Exit:

Exit Sub

数据更新前提醒_Err:

MsgBox Error$

Resume 数据更新前提醒_Exit

End Sub

Private Sub Form_Close()

On Error Resume Next

Forms("快递查询").数据表子窗体.Form.Requery

End Sub

快递数据表

数据表形式窗体

Private Sub 快递ID_DblClick(Cancel As Integer)

DoCmd.OpenForm "快递管理", acNormal, , "快递ID=" & Me.快递ID

End Sub

快递添加

文本框,组合框,按钮

Private Sub Command清空_Click()

快递类型.Value = ""

快递单号.Value = ""

物品.Value = ""

物品类别.Value = ""

重量.Value = ""

备注说明.Value = ""

存放位置.Value = ""

End Sub

Private Sub Command添加_Click()

If 快递类型 = "" Or IsNull(快递类型) = True Then

MsgBox "快递类型值为空!"

Exit Sub

End If

If 快递单号 = "" Or IsNull(快递单号) = True Then

MsgBox "快递单号值为空!"

Exit Sub

End If

If 物品 = "" Or IsNull(物品) = True Then

MsgBox "物品值为空!"

Exit Sub

End If

If 物品类别 = "" Or IsNull(物品类别) = True Then

MsgBox "物品类别值为空!"

Exit Sub

End If

If 重量 = "" Or IsNull(重量) = True Then

MsgBox "重量值为空!"

Exit Sub

End If

DoCmd.SetWarnings (False)

DoCmd.OpenQuery "快递添加查询", acViewNormal

If MsgBox("添加完成,是否打开快递管理窗体", vbYesNo) = vbYes Then

DoCmd.OpenForm "快递管理", acNormal, , "快递ID=" & Nz(DMax("快递ID", "快递表"), 0)

End If

Me.Requery

End Sub

收件查询

组合框,文本框,按钮,子窗体

Private Sub Command报表_Click()

If Me.数据表子窗体.Form.FilterOn = False Then

DoCmd.OpenReport "收件报表", acViewReport

Else

DoCmd.OpenReport "收件报表", acViewReport, , Me.数据表子窗体.Form.Filter

End If

End Sub

Private Sub Command查询_Click()

If Me.查询类型 <> "" And Me.查询内容 <> "" Then

Me.数据表子窗体.Form.Filter = Me.查询类型 & " like '*" & Me.查询内容 & "*'"

Me.数据表子窗体.Form.FilterOn = True

Else

Me.数据表子窗体.Form.FilterOn = False

End If

End Sub

Private Sub Command全部_Click()

Me.数据表子窗体.Form.FilterOn = False

End Sub

收件查询数据表

数据表形式窗体

Private Sub 收件单号_DblClick(Cancel As Integer)

DoCmd.OpenForm "收件管理", acNormal, , "收件单号='" & Me.收件单号 & "'"

End Sub

收件管理

文本框,组合框,按钮,复选框,绑定记录窗体

Private Sub Command更新_Click()

If 收件单号.Value <> "" And 快递公司.Value <> "" And 寄件地点.Value <> "" And 收件人.Value <> "" And 收件地址.Value <> "" And 收件人联系方式.Value <> "" _

And 取件学生.Value <> "" And 取件类型.Value <> "" And 收件日期.Value <> "" And 取件时间.Value <> "" Then

On Error Resume Next

DoCmd.RunCommand acCmdSaveRecord

Else

MsgBox "快递类型,快递单号,物品,物品类别,重量不能为空"

On Error Resume Next

DoCmd.RunCommand acCmdUndo

Exit Sub

End If

If Error.Number <> 0 Then

MsgBox Error.Description

End If

End Sub

Private Sub Command删除_Click()

On Error Resume Next

DoCmd.SetWarnings (False)

If MsgBox("是否删除该收件记录?", vbYesNo) = vbYes Then

DoCmd.RunCommand acCmdDeleteRecord

MsgBox "删除成功"

DoCmd.Close acForm, Me.Name

Else

Exit Sub

End If

If Error.Number <> 0 Then

MsgBox Error.Description

End If

End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)

If 收件单号.Value <> "" And 快递公司.Value <> "" And 寄件地点.Value <> "" And 收件人.Value <> "" And 收件地址.Value <> "" And 收件人联系方式.Value <> "" _

And 取件学生.Value <> "" And 取件类型.Value <> "" And 收件日期.Value <> "" And 取件时间.Value <> "" Then

On Error GoTo 数据更新前提醒_Err

If (MsgBox("是否保存对记录的修改", 1, "修改记录提醒") = 1) Then

Beep

Else

DoCmd.RunCommand acCmdUndo

End If

Else

MsgBox "收件单号,快递公司,寄件地点,收件人,收件地址,收件人联系方式,取件学生,取件类型,收件日期,取件时间不能为空"

On Error Resume Next

DoCmd.RunCommand acCmdUndo

Exit Sub

End If

数据更新前提醒_Exit:

Exit Sub

数据更新前提醒_Err:

MsgBox Error$

Resume 数据更新前提醒_Exit

End Sub

Private Sub Form_Close()

On Error Resume Next

Forms("收件查询").数据表子窗体.Form.Requery

End Sub

收件添加

文本框,组合框,按钮,复选框

Private Sub Command清空_Click()

收件单号.Value = ""

快递公司.Value = ""

寄件地点.Value = ""

收件人.Value = ""

收件地址.Value = ""

收件人联系方式.Value = ""

寄件人.Value = ""

寄件地址.Value = ""

寄件人联系方式.Value = ""

取件学生.Value = ""

取件人联系方式.Value = ""

取件类型.Value = ""

收件日期.Value = ""

取件时间.Value = ""

是否已取件.Value = False

备注说明.Value = ""

End Sub

Private Sub Command添加_Click()

If 收件单号 = "" Or IsNull(收件单号) = True Then

MsgBox "收件单号值为空!"

Exit Sub

End If

If 快递公司 = "" Or IsNull(快递公司) = True Then

MsgBox "快递公司值为空!"

Exit Sub

End If

If 寄件地点 = "" Or IsNull(寄件地点) = True Then

MsgBox "寄件地点值为空!"

Exit Sub

End If

If 收件人 = "" Or IsNull(收件人) = True Then

MsgBox "收件人值为空!"

Exit Sub

End If

If 收件地址 = "" Or IsNull(收件地址) = True Then

MsgBox "收件地址值为空!"

Exit Sub

End If

If 收件人联系方式 = "" Or IsNull(收件人联系方式) = True Then

MsgBox "收件人联系方式值为空!"

Exit Sub

End If

If 取件学生 = "" Or IsNull(取件学生) = True Then

MsgBox "取件学生值为空!"

Exit Sub

End If

If 取件类型 = "" Or IsNull(取件类型) = True Then

MsgBox "取件类型值为空!"

Exit Sub

End If

If 收件日期 = "" Or IsNull(收件日期) = True Then

MsgBox "收件日期值为空!"

Exit Sub

End If

If 取件时间 = "" Or IsNull(取件时间) = True Then

MsgBox "取件时间值为空!"

Exit Sub

End If

If Nz(DCount("收件单号", "收件表", "收件单号='" & Me.收件单号 & "'"), 0) > 0 Then

MsgBox "该收件单号已存在!"

Exit Sub

End If

Dim add_rs As DAO.Recordset

Set add_rs = CurrentDb.OpenRecordset("收件表", dbOpenTable)

With add_rs

.AddNew

!收件单号.Value = 收件单号.Value

!快递公司.Value = 快递公司.Value

!寄件地点.Value = 寄件地点.Value

!收件人.Value = 收件人.Value

!收件地址.Value = 收件地址.Value

!收件人联系方式.Value = 收件人联系方式.Value

!寄件人.Value = 寄件人.Value

!寄件地址.Value = 寄件地址.Value

!寄件人联系方式.Value = 寄件人联系方式.Value

!取件学生.Value = 取件学生.Value

!取件人联系方式.Value = 取件人联系方式.Value

!取件类型.Value = 取件类型.Value

!收件日期.Value = 收件日期.Value

!取件时间.Value = 取件时间.Value

!是否已取件.Value = 是否已取件.Value

!备注说明.Value = 备注说明.Value

.Update

.Close

End With

Set add_rs = Nothing

MsgBox "添加完成"

Me.Requery

End Sub

Private Sub Form_Load()

Me.是否已取件.Value = False

End Sub

Private Sub 取件时间_DblClick(Cancel As Integer)

Me.取件时间.Value = Now

End Sub

Private Sub 取件学生_AfterUpdate()

If Me.取件学生 <> "" Then

Me.取件人联系方式 = Nz(DLookup("联系方式", "学生表", "学号='" & Me.取件学生 & "'"), "")

Else

Me.取件人联系方式 = ""

End If

End Sub

Private Sub 取件学生_Change()

If Me.取件学生 <> "" Then

Me.取件人联系方式 = Nz(DLookup("联系方式", "学生表", "学号='" & Me.取件学生 & "'"), "")

Else

Me.取件人联系方式 = ""

End If

End Sub

Private Sub 收件日期_DblClick(Cancel As Integer)

Me.收件日期.Value = Date

End Sub

学生管理

表格布局,文本框,组合框,按钮

Private Sub Command保存_Click()

DoCmd.RunCommand acCmdSave

End Sub

Private Sub Command清空_Click()

学号添加.Value = ""

姓名添加.Value = ""

性别添加.Value = ""

班级添加.Value = ""

专业添加.Value = ""

宿舍添加.Value = ""

联系方式添加.Value = ""

End Sub

Private Sub Command添加_Click()

If 学号添加 = "" Or IsNull(学号添加) = True Then

MsgBox "学号值为空!"

Exit Sub

End If

If 姓名添加 = "" Or IsNull(姓名添加) = True Then

MsgBox "姓名值为空!"

Exit Sub

End If

DoCmd.SetWarnings (False)

Dim add_sql As String

add_sql = "Insert Into 学生表 (学号,姓名,性别,班级,专业,宿舍,联系方式) Values ('" & 学号添加 & "','" & 姓名添加 & "','" & 性别添加 & "','" & 班级添加 & "','" & 专业添加 & "','" & 宿舍添加 & "','" & 联系方式添加 & "')"

DoCmd.RunSQL add_sql

MsgBox "添加完成"

Me.Requery

End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)

If 学号.Value <> "" And 姓名.Value <> "" Then

On Error GoTo 数据更新前提醒_Err

If (MsgBox("是否保存对记录的修改", 1, "修改记录提醒") = 1) Then

Beep

Else

DoCmd.RunCommand acCmdUndo

End If

Else

MsgBox "学号,姓名不能为空"

On Error Resume Next

DoCmd.RunCommand acCmdUndo

Exit Sub

End If

数据更新前提醒_Exit:

Exit Sub

数据更新前提醒_Err:

MsgBox Error$

Resume 数据更新前提醒_Exit

End Sub

Private Sub 学号_DblClick(Cancel As Integer)

If MsgBox("是否删除该学生记录:" & Me.学号 & " ?", vbYesNo) = vbYes Then

DoCmd.SetWarnings (False)

DoCmd.OpenQuery "学生删除查询", acViewNormal

MsgBox "删除完成"

Me.Requery

End If

End Sub

标签: #校园导航系统课程设计c语言代码怎么写