基于查询的特定列表框的空白列不被识别为空或空 [英] The blank column of the particular List Box based on query is not recognized as either empty or null

查看:101
本文介绍了基于查询的特定列表框的空白列不被识别为空或空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

列表框: SearchList 从以下查询中获取数据: Machine_Search 。因此,输入我的序列号进入搜索文本框,然后按按钮搜索,然后选择显示在 SearchList上的记录。选择记录后,然后按编辑。条件是,如果我使用序列号搜索的记录在 End_Date 中具有空字段,则记录会顺利进​​行。但是,如果使用序列号搜索的记录在 End_Date 中具有日期,它将提示一个msgbox,然后关闭然后再次打开表单。问题在于无法检测到 End_Date 为空还是空,并且无论条件如何都会提示msgbox。

The Listbox: SearchList get data from the query: Machine_Search.So how it works is i input my Serial Number into the Search textbox and press the button search then select the record displayed on the SearchList. When the record is selected, i then press edit. The condition is that if the record that i search using Serial Number have empty field in the End_Date it will go on smoothly. However if the record that is search using Serial Number have a date in the End_Date it will prompt a msgbox and, close and open the form again. The issue lies at where it cannot detect if End_Date is null or empty and will prompt the msgbox regardless of the condition.

表格:机器

查询:Machine_Search-它查询表格:具有以下形式的机器: Machine_Load 会填充表格中一半的字段,而另一个将由 Machine_Unload /

Query: Machine_Search - It query the table:Machine where there is a form called: Machine_Load which fills half the field in the table and the other will be filled by Machine_Unload/

Form:Machine_Unload

Form:Machine_Unload

是否可以解决此问题?

Private Sub cmdSearch_Click()
Dim check As String
    DoCmd.OpenQuery "Machine_Search"
    DoCmd.Close acQuery, "Machine_Search"
    SearchList.Requery

    If SearchList.ListCount = 0 Then
        MsgBox ("No records found.")
        DoCmd.Close
        DoCmd.OpenForm "Machine_Unload"
        Exit Sub
    End If

    Me.cmdEdit.Enabled = True
    Me.cmdSearch.Enabled = False
    Me.txtSN.Enabled = True
    Me.txtDate.Enabled = True
    Me.txtTime.Enabled = True
    Me.CheckTime.Enabled = True
    Me.ListSuccess.Enabled = True
    Me.txtOperator.Enabled = True
    Me.txtRemarks.Enabled = True
    Me.txtSearch.Enabled = False
    Me.txtSN.SetFocus
End Sub



Private Sub cmdEdit_Click()

On Error GoTo Err_cmdEdit_Click
Dim SN_Value As String
Dim Date_Value As String
    If Me.SearchList.ListIndex > -1 Then
        SN_Value = Me.SearchList.Value
        Date_Value = Me.SearchList.Column(5)

        If Not IsEmpty(Date_Value) Then
            MsgBox ("The Unload data for this Serial Number have been filled, Please confirm with cell leader.")
            DoCmd.Close
            DoCmd.OpenForm "Esagon_Unload"
            Exit Sub
        End If
    End If

    'check whether there exists data in list
    If Not (Me.SearchList.Recordset.EOF And Me.SearchList.Recordset.BOF) Then
        'get data to text box control
        With Me.SearchList.Recordset
            Me.txtSN = .Fields("Serial_Number")
            'store id of serial number in tag of txtSN in case id is modified
            Me.txtSN.Tag = .Fields("Serial_Number")
            'Disable button edit
            Me.cmdEdit.Enabled = False
            Me.cmdUpdate.Enabled = True

        End With
    End If

End_Err:
Exit Sub


Err_cmdEdit_Click:
MsgBox ("Select the Serial Number." & vbCrLf & "Please try again and click on the Serial Number below.")
DoCmd.Close
DoCmd.OpenForm "Machine_Unload"
Resume End_Err

End Sub



SELECT Machine.Serial_Number, Machine.End_Date, Machine.End_Time, Machine.End_System_Time, Machine.End_Operator, Machine.Success, Machine.End_Remarks
FROM Machine
WHERE (((Machine.Serial_Number)=[Forms]![Machine_Unload]![txtSearch]));


推荐答案

IsEmpty 不适用这种用法。尝试:

IsEmpty is not for this usage. Try:

If Not IsNull(Date_Value) Then

或:

If Nz(Date_Value) <> "" Then

这篇关于基于查询的特定列表框的空白列不被识别为空或空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆