访问。无效带组合框的“编辑”按钮

问题描述 投票:0回答:1

存在具有相关性的级联组合框。每个组合框都包含一个表的值。选择所有值后,将它们添加到一个数据透视表中。

问题出现在编辑按钮上,该按钮应该从数据透视表中移出一行,然后将值放回到组合框中。使用我的代码,组合框保持为空。 (文本框充满了此内容)有关如何修复代码的任何想法?

   Private Sub btnAdd_Click()
    'add data to table

    CurrentDb.Execute "INSERT INTO toolList(numberTool, roughFinish, application, dim, tool, holder, h, f, s, offsetR, d, toolLife, corNumber, pictureSource, dms) " & _
    " VALUES('" & Me.cboNumberTool.Column(1) & "','" & Me.cboRoughFinish.Column(1) & "','" & Me.cboApplication.Column(1) & "','" & (Me.txtLabelDim.Caption & " " & Me.txtDim) & "','" & Me.cboTool.Column(1) & "','" & _
    (Me.cboHolder.Column(1) & " " & Me.cboMmaster.Column(1) & " " & Me.cboCollet.Column(1) & " " & Me.cboShrink.Column(1) & " " & Me.cboStrshank.Column(1)) & "','" & _
    Me.txtH & "','" & Me.txtF & "','" & _
    Me.txtS & "','" & Me.txtOffsetR & "','" & Me.txtD & "','" & Me.txtToolLife & "','" & Me.txtCorNumber & "','" & Me.txtPictureSource & "','" & Me.txtDms & "')"

    'refresh data in list on form
    ToolListsub.Form.Requery  
End Sub


Private Sub btnEdit_Click()
'check whether there exists data in list
If Not (Me.ToolListsub.Form.Recordset.EOF And Me.ToolListsub.Form.Recordset.BOF) Then
    'get data to text box control
    With Me.ToolListsub.Form.Recordset
        Me.cboRoughFinish = .Fields("roughFinish")
        Me.cboApplication = .Fields("application")
        Me.txtDim = .Fields("dim")
        Me.cboNumberTool = .Fields("numberTool")
        Me.cboTool = .Fields("tool")
        Me.cboHolder = ""
        Me.cboCollet = ""
        Me.cboMmaster = ""
        Me.cboShrink = ""
        Me.cboStrshank = ""
        Me.txtH = .Fields("h")
        Me.txtF = .Fields("f")
        Me.txtS = .Fields("s")
        Me.txtOffsetR = .Fields("offsetR")
        Me.txtD = .Fields("d")
        Me.txtToolLife = .Fields("toolLife")
        Me.txtCorNumber = .Fields("corNumber")
        Me.txtPictureSource = .Fields("pictureSource")
       End With
    End If
End Sub
vba ms-access combobox access-vba
1个回答
0
投票

谢谢!早就明白了,但最终结果还是。这是代码,有人可以派上用场了。cboRoughFinish = DLookup(“ ID”,“ roughFinish”,“ Value ='”&.Fields(“ roughFinish”)&“'”)

© www.soinside.com 2019 - 2024. All rights reserved.