文本框 [英] Text boxes
问题描述
我正在使用Access 2007,我正在尝试做一些非常简单的事情我有一个带有两个文本框和一个按钮的表单。当用户按下按钮时,如果该框为空白,则会显示一条消息。如果用户输入了她的姓名,则将显示包含该信息的另一条消息。我有下面的代码,但我不明白为什么代码不运行。我正在编写按钮下的代码。请帮忙。感谢
选项比较数据库
选项明确
私有子Command4_Click()
如果IsNull(Me.txtFirst.Value)或IsNull(Me.txtSecond.Value)那么
MsgBox空白
否则
MsgBox你的名字是 &安培; Me.txtFirst.Value& 而你的年龄是 &安培; Me.txtSecond.Value
结束如果
结束Sub
Hi, I am using Access 2007 and I am trying to do something really simple I have a form with two text boxes and a button. When the user press the button if the box is blank a message will be display. If the user inputs his her name another message will be display with that info. I have the code below, however I do not understand why the code does not run. I am writing the code under the button. Please help. Thanksss
Option Compare Database
Option Explicit
Private Sub Command4_Click()
If IsNull(Me.txtFirst.Value) Or IsNull(Me.txtSecond.Value) Then
MsgBox "Is Blank"
Else
MsgBox "Your name is" & Me.txtFirst.Value & "And your age is" & Me.txtSecond.Value
End If
End Sub
推荐答案
我正在使用Access 2007,我正在尝试做一些非常简单的事情我有一个带有两个文本框和一个按钮的表单。当用户按下按钮时,如果该框为空白,则会显示一条消息。如果用户输入了她的姓名,则将显示包含该信息的另一条消息。我有下面的代码,但我不明白为什么代码不运行。我正在编写按钮下的代码。请帮忙。感谢
选项比较数据库
选项明确
私有子Command4_Click()
如果IsNull(Me.txtFirst.Value)或IsNull(Me.txtSecond.Value)那么
MsgBox空白
否则
MsgBox你的名字是 &安培; Me.txtFirst.Value& 而你的年龄是 &安培; Me.txtSecond.Value
结束如果
结束次级
Hi, I am using Access 2007 and I am trying to do something really simple I have a form with two text boxes and a button. When the user press the button if the box is blank a message will be display. If the user inputs his her name another message will be display with that info. I have the code below, however I do not understand why the code does not run. I am writing the code under the button. Please help. Thanksss
Option Compare Database
Option Explicit
Private Sub Command4_Click()
If IsNull(Me.txtFirst.Value) Or IsNull(Me.txtSecond.Value) Then
MsgBox "Is Blank"
Else
MsgBox "Your name is" & Me.txtFirst.Value & "And your age is" & Me.txtSecond.Value
End If
End Sub
Margot,
Nulls没有价值,所以测试如下:
If IsNull(Me.txtFirst)或IsNull(Me.txtSecond)然后
如果您在文本框中允许零长度字符串(ZLS)(例如,点击空格键),您需要检查文本框中的空格以及空值......两者都显示为空白。您可以按如下方式测试两者:
如果Nz(Me.txtFirst,"")=""或Nz(Me.txtSecond,"")=""然后
Margot,
Nulls don''t have a value, so test like this:
If IsNull(Me.txtFirst) Or IsNull(Me.txtSecond) Then
If you allow zero length strings (ZLS) in your textboxes (e.g hitting the spacebar) you need to check the textboxes for spaces as well as nulls...both appear as blank. You can test for both as follows:
If Nz(Me.txtFirst, "") = "" Or Nz(Me.txtSecond, "") = "" Then
Margot,
Nulls没有价值,所以测试就好这个:
如果IsNull(Me.txtFirst)或IsNull(Me.txtSecond)那么
如果允许零长度您的文本框中的字符串(ZLS)(例如,按空格键)您需要检查文本框中的空格和空值...两者都显示为空白。您可以按如下方式测试两者:
如果Nz(Me.txtFirst,"")=""或Nz(Me.txtSecond,"")=""然后
Margot,
Nulls don''t have a value, so test like this:
If IsNull(Me.txtFirst) Or IsNull(Me.txtSecond) Then
If you allow zero length strings (ZLS) in your textboxes (e.g hitting the spacebar) you need to check the textboxes for spaces as well as nulls...both appear as blank. You can test for both as follows:
If Nz(Me.txtFirst, "") = "" Or Nz(Me.txtSecond, "") = "" Then
谢谢,
我尝试了第一个选项,下面的代码。但它似乎不起作用。不知道为什么?谢谢
选项比较数据库
选项明确
私有子Command4_Click()
如果IsNull(Me.txtFirst)或IsNull(Me.txtSecond)那么
MsgBox是空白的
否则
MsgBox"你的名字是 &安培; Me.txtFirst.Value& 而你的年龄是 &安培; Me.txtSecond.Value
结束如果
End Sub
Thank you,
I tried the first option, the code below. However it does not seem to work. Don''t know why?? Thanks
Option Compare Database
Option Explicit
Private Sub Command4_Click()
If IsNull(Me.txtFirst) Or IsNull(Me.txtSecond) Then
MsgBox "Is Blank"
Else
MsgBox "Your name is" & Me.txtFirst.Value & "And your age is" & Me.txtSecond.Value
End If
End Sub
谢谢,
我尝试了第一个选项,下面的代码。但它似乎不起作用。不知道为什么?谢谢
选项比较数据库
选项明确
私有子Command4_Click()
如果IsNull(Me.txtFirst)或IsNull(Me.txtSecond)那么
MsgBox是空白的
否则
MsgBox"你的名字是 &安培; Me.txtFirst.Value& 而你的年龄是 &安培; Me.txtSecond.Value
结束如果
结束子
Thank you,
I tried the first option, the code below. However it does not seem to work. Don''t know why?? Thanks
Option Compare Database
Option Explicit
Private Sub Command4_Click()
If IsNull(Me.txtFirst) Or IsNull(Me.txtSecond) Then
MsgBox "Is Blank"
Else
MsgBox "Your name is" & Me.txtFirst.Value & "And your age is" & Me.txtSecond.Value
End If
End Sub
Margot ,
您可能需要使用第二个选项,因为您的字段包含空格,这与空格不同。
Margot,
You probably need to use the second option because your field contains spaces, which is different from null.
这篇关于文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!