Is there a way to clear a textbox other than.
Text1.text = ""
Printable View
Is there a way to clear a textbox other than.
Text1.text = ""
You can also use API like this:
VB Code:
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long SetWindowText Text1.hwnd, ""
That's a bit much. What I was trying to hit at was if there is a function that can clear a textbox, because this form I have in Access acts funny when I clear the two date formatted text boxes with = "".
Are your textboxes bound or unbound ?
If they're unbound, you should have no problems ?
Pee
What do you mean by "acts funny"?
It sings and it dances.
It causes errors what else?
ooooh !
Instead of assigning a format to the textbox (assuming you have?), put some formatting on the values in code in the lostfocus event or somesuch....
You can then trap any errors that arise from the data not being validat against the Access Format.
Pee
Just a suggestion, .... but you'd be better off by putting all your code into a VB form, and leaving the Access database to just be a database.
perhaps this project is only access.
what about
text1 = ""
or
text1 = vbnullstring
;)
might work ;)
In Access you have to set the FOCUS to the textbox before you can clear it.
I'm just saying, .... to avoid headaches down the road, make it in VB. Maybe he can't. It's just a suggestion.
Goes to show how much you know about Access.
You don't need to set the focus. Only when you use the text property do you need to use the setfocus().
Just clear textboxes like
Text1 = ""
And this is in Access 97, I'm working for a company and they do not have VB compilers.
Hmm, how to win friends and influence people !!Quote:
Originally posted by JaredM
Goes to show how much you know about Access.
Well, nice to know any suggestions & help are appreciated....:mad:
Yeah really huh? Go figure.
I could be mean and say something about "VB compilers", but i'm not going to.
I was kidding. Maybe I should've put a smiley next to it. :eek:
I figured out the problem. I had to set the formatting property on the textbox in access in addition to the input mask.
That work :
VB Code:
Option Explicit Private Sub Form_Load() Dim Clear As String Text1 = Clear End Sub
But, doesn't Clear contain "" which is what he is trying to avoid?
Don't worry peeps I've got it to run properly now. Course it's a little bit cheesy, but the end user won't be able to see it going on.
As long as it works.
What did you do? I'm curious.
I know that but he wanted to avoid the "" so a empty variable is equal to "" but you do not see it... Anyways, I do not see what is wrong with "" .Quote:
But, doesn't Clear contain "" which is what he is trying to avoid?
what's the point of 4 lines if you can do it in 1?
text1 = ""
that will work the same, if not better than your little (big) example
There was a property called FORMAT in the textbox control for Access. I threw in the proper formatting and the problem went away.