Testing if a textbox is empty in VBA
Luis
-
swissi -
swissi -
Hello,
I am currently creating a form in Access.
I have two independent fields named: User and Passwd.
I also have a button labeled OK.
I would like a window to pop up when I click the button if either of the two textboxes is empty.
Here is the code I have:
If User = Null Or Passwd = Null Then
MsgBox "Please enter a username and a password"
End If
But it doesn't work.
A little help would be greatly appreciated please.
Thank you
Luis
I am currently creating a form in Access.
I have two independent fields named: User and Passwd.
I also have a button labeled OK.
I would like a window to pop up when I click the button if either of the two textboxes is empty.
Here is the code I have:
If User = Null Or Passwd = Null Then
MsgBox "Please enter a username and a password"
End If
But it doesn't work.
A little help would be greatly appreciated please.
Thank you
Luis
8 answers
Glad to hear that!
Don't forget to also test for the empty value, which is not "null" (if the user starts typing and then deletes...)
--
See you later, Blux
Don't forget to also test for the empty value, which is not "null" (if the user starts typing and then deletes...)
If IsNull(User.Value) or User.Value = "" Then...
--
See you later, Blux
"The fools will try anything. That's how you recognize them."
Hi,
it's normal, null is not tested as a value, but with a function :
--
See you, Blux
it's normal, null is not tested as a value, but with a function :
If IsNull(User.value)...
--
See you, Blux
"Stupidity dares everything. That's how we recognize them."
I just have one last question:
Do you know which font I should use for the textbox containing the password?
So that it only shows black dots...
Do you know which font I should use for the textbox containing the password?
So that it only shows black dots...
It's not a police story, but rather a formatting story; you have to choose "password" or "mot de passe," and that's what will display either stars or "black dots"... (data tab of the textbox, field "input mask")...
--
A+ Blux
--
A+ Blux
"Stupid people dare to do anything. It's even how you recognize them."
Hello
I'm developing a form and I want to validate the value of a TextBox that must be a non-zero integer
What should I do?
I wrote this but it doesn't work:
Private Sub TextBox1_Change()
Dim KeyAscii As MSForms.ReturnInteger
Select Case KeyAscii
Case Is < 49, Is > 57
MsgBox "Only a non-zero integer is allowed."
KeyAscii = Asc(Chr(8))
End Select
End Sub
I'm developing a form and I want to validate the value of a TextBox that must be a non-zero integer
What should I do?
I wrote this but it doesn't work:
Private Sub TextBox1_Change()
Dim KeyAscii As MSForms.ReturnInteger
Select Case KeyAscii
Case Is < 49, Is > 57
MsgBox "Only a non-zero integer is allowed."
KeyAscii = Asc(Chr(8))
End Select
End Sub