使用嵌套子表单在Access子窗体上创建主搜索表单

时间:2017-07-13 17:29:12

标签: sql-server vba ms-access access-vba ms-access-2013

我有一个表单 - EmployeeDataForm - 有多个子表单 - LockerSubForm,CurrentAssignmentSubForm等 - 在选项卡控件上分隔成不同的页面。

完全按照此视频的说明操作: https://youtu.be/N0X8Hg-Sm6A 我创建了一个额外的表单 - 员工搜索,并将EmployeeDataForm添加为子表单。

现在,拉起“员工搜索”表单会自动按预期显示所有记录。但是在搜索栏中输入任何内容并搜索会减少所有字段。

这是我的代码

Option Compare Database
Option Explicit

Private Sub btnSearch_Click()

    Dim SQL As String

    SQL = "SELECT [Current Employee].[Last Name], [Current Employee].[First Name], " _
    & "[Current Employee].[Employee ID], [Current Employee].[Badge ID#], [Current Employee].Email, " _
    & "[Current Employee].DOB, [Current Employee].Insurance, [Current Employee].[Health Assessment], " _
    & "[Current Employee].[TX Zone], [Current Employee].[Hire Date], [Current Employee].Shirts, " _
    & "[Current Employee].Pants, [Current Employee].Jackets " _
    & "FROM [Current Employee] " _
    & "WHERE [Last Name] = '*" & Me.txtKeywords & "*' " _
    & "ORDER BY [Current Employee].[Last Name];"

    Me.subEmployeeData.Form.RecordSource = SQL

    Me.subEmployeeData.Requery

End Sub

0 个答案:

没有答案