【发布时间】:2016-05-17 11:15:26
【问题描述】:
单击时我希望我的按钮在 me.txtAddNote 为空白时不添加文本,并显示一条消息提示用户输入文本或取消。当 me.txtAddNote 有文本时,我希望单击时输入文本。目前,我的代码在这两种情况下甚至在 msgbox 弹出之前都添加了文本。任何帮助表示赞赏,谢谢。
Private Sub cmdAddNote_Click()
Dim LName As String
On Error Resume Next
LName = DLookup("[LNAME]", "[qryEmpDepDes]", "[EMP_NO]='" & Me.txtUserID & "'")
[NOTES] = Date & ": " & Me.txtAddNote & " (" & Me.txtUserID & " " & LName & ")" & vbNewLine & vbNewLine & [NOTES]
Me.txtAddNote = ""
Me.cmdAddNote.Enabled = True
Me.cmdClose.Enabled = True
Me.cmdClose.SetFocus
'5-16-2016 testing blank text box'
If Me.txtAddNote = "" Then
If MsgBox("No text is entered. Hit OK to enter text. Hit CANCEL to close out.", vbOKCancel) = vbOK Then
End If
Else
DoCmd.Close
End If
结束子
【问题讨论】: