0

我有一个简单的库存数据库,带有一个简单的搜索文本选项,可以将其过滤到那些特定的项目。我想根据当前过滤的内容“签出/签入”多个项目。

因此,如果我查找“float”,在拆分表单中它只会显示其描述中包含“float”的任何内容的所有信息。从那里我想要一个按钮(“签出”)来检查此文本框过滤器的所有结果是否为真,而不是单击每个项目。我附上了一张我的表格的照片。访问示例照片

4

2 回答 2

1

向执行某些 SQL 的按钮添加一些代码,以更新复选框后面的记录状态。这是一个带有打印语句的示例,用于显示查询字符串在执行之前会变成什么:

Private Sub CheckInButton_Click()

DoCmd.SetWarnings False

sqlString = "UPDATE tbl_inventory SET tbl_inventory.Packed = False WHERE tbl_inventory.Item like '" & Me.txtFilter & "'" 

debug.print sqlString

DoCmd.RunSQL sqlString 

DoCmd.SetWarnings True

Me.SubForm.Requery

End Sub
于 2018-05-01T00:14:35.630 回答
0

JShort set me onto the answer. This is how I did this incase there's another newbie out there.

As suggested I created two update queries (qry_CheckIn / qry_CheckOut).
In my field "Packed" (the checkbox) I set the Update To: 0 (Remove the checkmark) / -1 (Add the checkmark).

In my field "Item" I put:

    Like "*" & [Forms]![frm_inventory]![txtFilter] & "*"

Which looks in my forms at my text filter search box (see image in question section).

Next part: (If you have a newer version of access turn on "Show All Actions") I added the macro commands "on click" for each of my buttons in this order:

  1. SetWarnings

    Warnings On - No

  2. OpenQuery

    Query Name - qry_CheckIn (or Out)

  3. RunMenuCommand

    Command - Refresh

  4. SetWarnings

    Warning On - Yes

Thanks for the assist JShort.

于 2018-05-02T14:43:13.587 回答