如果访问表选择了新记录,则会显示“(新建)”.如何让我的代码识别(新)值



我希望能够让数据库的最终用户知道他们何时在新记录上,但我不想显示实际的 id。我只希望文本框在新记录时显示"新建"。

我有两个按钮,一个选择上一条记录,另一个选择下一条记录。下一个记录按钮包含我正在尝试工作的代码。

Private Sub Command25_Click()
On Error GoTo Command25_Click_Err
    On Error Resume Next
    DoCmd.GoToRecord , "", acNext
    ' I wrote this if statment to capture the (New)
    If frmQuote_QuoteID.Value = " " Then
        frmQuote_QuoteNumber.Value = "NEW"
    End If
    If (MacroError <> 0) Then
        Beep
        MsgBox MacroError.Description, vbOKOnly, ""
    End If

Command25_Click_Exit:
    Exit Sub
Command25_Click_Err:
    MsgBox Error$
    Resume Command25_Click_Exit
End Sub

我也尝试过如果 frmQuote_QuoteID.value = "(New)" 那么

我正在尝试将其达到表单可以根据空主键字段显示 New 的程度,但如果它不是新记录,那么我不希望显示任何内容

你需要使用

if me.NewRecord then

最新更新