使用rst![]填写附件字段(Access VBA)

时间:2018-10-30 19:13:33

标签: ms-access access-vba ms-access-2016

我正在使用一个访问数据库,该数据库允许用户单击表单上的条目以显示特定条目的更多详细信息。它使用rst(我不熟悉)执行此操作。我已经编写了代码:Attachment1 = rst![Doc],并在从中提取信息的表中添加了正确的字段,但是我收到以下消息:

运行时错误“ 438”

对象不支持此属性或方法

我在这里做错什么,我该怎么解决?

我写的代码就是抛出标志的地方。我猜第一个不适用于附件字段,因为我添加了一个文本字段,并且效果很好。我还尝试将表链接到表单,并使该字段成为附件框的控制源,但是这导致每个“详细信息”部分都使用附件字段的顶行,而不是每个条目都有自己的行。 / p>

编辑:这是我的代码,直到抛出错误为止

Dim rst作为DAO.Recordset Dim rstLabels作为DAO.Recordset 调暗twoPerBox为布尔值 Dim showDDA为布尔 Dim isSearching as Boolean

If tree_PTTInfo.SelectedItem Is Nothing Then
    GoTo Good_Exit
End If

'check how many PTTs can fit in a box
Set rst = CurrentDb.OpenRecordset("SELECT tbl_Products.[MaxInBox], tbl_OrderGroup.[ProdID]" & _
    ", tbl_ProductTypes.[isGSM]" & _
    " FROM [tbl_OrderGroup] INNER JOIN" & _
    " ([tbl_Products] INNER JOIN [tbl_ProductTypes] ON tbl_Products.[TypeID] = tbl_ProductTypes.[TypeID])" & _
    " ON tbl_OrderGroup.[ProdID] = tbl_Products.[ProdID]" & _
    " WHERE tbl_OrderGroup.[GroupID] = " & CInt(Right(tree_PTTInfo.SelectedItem.key, Len(tree_PTTInfo.SelectedItem.key) - 3)), , dbReadOnly)

isSearching = False
If rst.EOF Then
    Set rst = CurrentDb.OpenRecordset("SELECT tbl_Products.[MaxInBox], qry_OrderGroup_All.[ProdID]" & _
    ", tbl_ProductTypes.[isGSM]" & _
    " FROM [qry_OrderGroup_All] INNER JOIN" & _
    " ([tbl_Products] INNER JOIN [tbl_ProductTypes] ON tbl_Products.[TypeID] = tbl_ProductTypes.[TypeID])" & _
    " ON qry_OrderGroup_All.[ProdID] = tbl_Products.[ProdID]" & _
    " WHERE qry_OrderGroup_All.[GroupID] = " & CInt(Right(tree_PTTInfo.SelectedItem.key, Len(tree_PTTInfo.SelectedItem.key) - 3)), , dbReadOnly)
    isSearching = True
End If

twoPerBox = False
If rst![MaxInBox] = 2 And rst![ProdID] <> DummyProdID Then
    twoPerBox = True
End If

showDDA = False
If rst![isGSM] Then
    showDDA = True
End If

'get the OrderGroup record
Set rst = CurrentDb.OpenRecordset("SELECT * FROM [tbl_OrderGroup]" & _
    " WHERE [GroupID] = " & CInt(Right(tree_PTTInfo.SelectedItem.key, Len(tree_PTTInfo.SelectedItem.key) - 3)), , dbReadOnly)

If rst.EOF Then
    Set rst = CurrentDb.OpenRecordset("SELECT * FROM [qry_OrderGroup_All]" & _
        " WHERE [GroupID] = " & CInt(Right(tree_PTTInfo.SelectedItem.key, Len(tree_PTTInfo.SelectedItem.key) - 3)), , dbReadOnly)
End If

If rst![isPTT] Then
    lbl_PTTInfo.Caption = "PTT Information - " & rst![GroupDesc]
    txtbx_ProductionID.Enabled = True
    txtbx_Species.Enabled = True
    txtbx_SpeciesWeight.Enabled = True
    txtbx_Location.Enabled = True
    Text585.Enabled = True
    Attachment595.Enabled = True

    txtbx_ProductionID = rst![ProductionID]
    txtbx_Species = rst![Species]
    txtbx_SpeciesWeight = rst![SpeciesWeight]
    txtbx_Location = rst![Location]
    Text585 = rst![Admin Notes]
    Attachment595 = rst![Prod Docs]

0 个答案:

没有答案