如何使用列表框控件正确处理新记录的输入?

时间:2018-02-15 18:05:20

标签: ms-access access-vba

我的表单上有一个列表框,这给了我一个错误。

ProductNo字段是主键。

当我部分输入新记录并决定离开ProductNo控件到列表框项目时,会发生此错误。

贝娄是我目前的噩梦:

Private Sub InventoryListBox_AfterUpdate()

    ' Find Record that matches the control.
    Dim rst As Object
    Set rst = Me.Recordset.Clone

    rst.FindFirst "[ProductNo] = '" & Me![ListBox] & "'"
    If Not rst.EOF Then
        Me.Bookmark = rst.Bookmark    'Error here!
    End If

End Sub

1 个答案:

答案 0 :(得分:0)

测试$(document).ready(function() { var infoForm = $('.form form'); infoForm.submit(function() { // create a var to reference this specific form var $thisForm = $(this); // assuming you want to only show the messages nearest to your form, // you can select the parent div and find the response divs in there too. // create a reference to the specific parent div (div class="form") var $parent = $thisForm.parent(); // these will reference the specific fields specific to this form var formSuccessMsg = $parent.find('p.success'); var formErrorMsg = $parent.find('p.error'); var url = $thisForm.attr('action') + '?showtemplate=false'; var emailInput = $thisForm.find('input[type=text]').val(); if( emailInput.length === 0 || emailInput == '' || !isValidEmailAddress(emailInput) ) { formErrorMsg.show(); return false; } else { $.post(url, $thisForm.serialize(), function(data, textStatus, jqXHR) { // alert('post came back'); $thisForm.hide(); formErrorMsg.hide(); formSuccessMsg.show(); console.log(emailInput); }); return false; } }); }); 属性而不是NoMatch属性,例如:

EOF

以上假设Private Sub InventoryListBox_AfterUpdate() Dim rst As Recordset Set rst = Me.RecordsetClone rst.FindFirst "[ProductNo] = '" & Me![ListBox] & "'" If Not rst.NoMatch Then Me.Bookmark = rst.Bookmark End If End Sub 是字符串值字段。