【批量生成記錄 簽到表格制作】【切換背景圖片和字體樣式】【切換引用鏈接表】
批量生成記錄 簽到表格制作
Private Sub Command生成簽到記錄_Click()
Dim search_rs As DAO.Recordset
Dim search_sql As String
search_sql = "Select * From 人員名單表"
Set search_rs = CurrentDb.OpenRecordset(search_sql, dbOpenDynaset)
Dim add_rs As DAO.Recordset
Set add_rs = CurrentDb.OpenRecordset("簽到記錄表", dbOpenTable)
With add_rs
Do While search_rs.EOF = False
'----------------------------------生成簽到記錄
.AddNew
!會議名稱.Value = 會議名稱.Value
!姓名.Value = search_rs!姓名.Value
!簽到.Value = False
!遲到.Value = False
!早退.Value = False
!請假.Value = False
.Update
search_rs.MoveNext
Loop
.Close
End With
Set add_rs = Nothing
search_rs.Close
Set search_rs = Nothing
Me.數(shù)據(jù)表子窗體.Requery
End Sub
切換背景圖片和字體樣式
Public a1 As Integer
Private Sub Command切換_Click()
If a1 = 0 Then
Me.Picture = CurrentProject.Path & "\" & "背景-晚上.jpg"
Me.Label標(biāo)題.ForeColor = RGB(255, 255, 255)
Me.Label標(biāo)題.FontName = "華文琥珀"
Me.Label標(biāo)題.FontBold = False
Me.Command切換.ForeColor = RGB(255, 255, 255)
Me.Command切換.BackColor = RGB(112, 128, 144)
a1 = 1
Else
Me.Picture = CurrentProject.Path & "\" & "背景-白天.jpg"
Me.Label標(biāo)題.ForeColor = RGB(0, 0, 0)
Me.Label標(biāo)題.FontName = "宋體"
Me.Label標(biāo)題.FontBold = True
Me.Command切換.ForeColor = RGB(255, 255, 255)
Me.Command切換.BackColor = RGB(70, 130, 180)
a1 = 0
End If
End Sub
Private Sub Form_Load()
a1 = 0
Me.Picture = CurrentProject.Path & "\" & "背景-白天.jpg"
Me.Label標(biāo)題.ForeColor = RGB(0, 0, 0)
Me.Label標(biāo)題.FontName = "宋體"
Me.Label標(biāo)題.FontBold = True
Me.Command切換.ForeColor = RGB(255, 255, 255)
Me.Command切換.BackColor = RGB(70, 130, 180)
End Sub
切換引用鏈接表
Private Sub Command切換_Click()
If Me.年份 <> "" Then
Call deltable("銷售數(shù)據(jù)表")
Call linktable(CStr(Me.年份 & "年銷售數(shù)據(jù)表"))
Me.數(shù)據(jù)表子窗體.SourceObject = "銷售數(shù)據(jù)表"
Me.數(shù)據(jù)表子窗體.Requery
End If
End Sub
Public Sub linktable(ByVal tname As String)
Dim dbImport As String
dbImport = CurrentProject.Path & "\銷售數(shù)據(jù).accdb"
Dim sPassword As String
sPassword = "1234"
Dim DB As DAO.Database
Set DB = DBEngine.OpenDatabase(Name:=dbImport, Options:=False, ReadOnly:=False, Connect:=";PWD=" & sPassword)
DoCmd.TransferDatabase acLink, "Microsoft Access", dbImport, acTable, tname, "銷售數(shù)據(jù)表"
? ? DB.Close
? ? Set DB = Nothing
End Sub
Public Sub deltable(ByVal tname As String)
On Error Resume Next
Dim deltsql As String
DoCmd.SetWarnings (False)
deltsql = "Drop TABLE " & tname
DoCmd.RunSQL deltsql
End Sub
Private Sub Form_Load()
Me.數(shù)據(jù)表子窗體.SourceObject = ""
End Sub