|
-
Dec 14th, 2001, 09:29 AM
#1
Thread Starter
Hyperactive Member
Clearing a Textbox
Is there a way to clear a textbox other than.
Text1.text = ""
-
Dec 14th, 2001, 09:47 AM
#2
PowerPoster
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, ""
-
Dec 14th, 2001, 09:50 AM
#3
Thread Starter
Hyperactive Member
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 = "".
-
Dec 14th, 2001, 09:57 AM
#4
Hyperactive Member
Are your textboxes bound or unbound ?
If they're unbound, you should have no problems ?
Pee

Best Bar.....
-
Dec 14th, 2001, 10:01 AM
#5
What do you mean by "acts funny"?
-
Dec 14th, 2001, 10:15 AM
#6
Thread Starter
Hyperactive Member
It sings and it dances.
It causes errors what else?
-
Dec 14th, 2001, 10:23 AM
#7
Hyperactive Member
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

Best Bar.....
-
Dec 14th, 2001, 10:33 AM
#8
Frenzied Member
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.
~Peter

-
Dec 14th, 2001, 10:35 AM
#9
Conquistador
perhaps this project is only access.
what about
text1 = ""
or
text1 = vbnullstring

might work
-
Dec 14th, 2001, 10:43 AM
#10
Frenzied Member
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.
~Peter

-
Dec 14th, 2001, 10:46 AM
#11
Thread Starter
Hyperactive Member
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.
-
Dec 14th, 2001, 10:59 AM
#12
Hyperactive Member
Originally posted by JaredM
Goes to show how much you know about Access.
Hmm, how to win friends and influence people !!
Well, nice to know any suggestions & help are appreciated....

Best Bar.....
-
Dec 14th, 2001, 11:10 AM
#13
Frenzied Member
Yeah really huh? Go figure.
I could be mean and say something about "VB compilers", but i'm not going to.
-
Dec 14th, 2001, 12:32 PM
#14
Thread Starter
Hyperactive Member
I was kidding. Maybe I should've put a smiley next to it.
I figured out the problem. I had to set the formatting property on the textbox in access in addition to the input mask.
-
Dec 14th, 2001, 12:34 PM
#15
That work :
VB Code:
Option Explicit
Private Sub Form_Load()
Dim Clear As String
Text1 = Clear
End Sub
-
Dec 14th, 2001, 03:23 PM
#16
But, doesn't Clear contain "" which is what he is trying to avoid?
-
Dec 14th, 2001, 03:31 PM
#17
Thread Starter
Hyperactive Member
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.
-
Dec 14th, 2001, 03:43 PM
#18
As long as it works.
What did you do? I'm curious.
-
Dec 14th, 2001, 03:59 PM
#19
But, doesn't Clear contain "" which is what he is trying to avoid?
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 "" .
-
Dec 14th, 2001, 07:58 PM
#20
Conquistador
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
-
Dec 18th, 2001, 08:29 AM
#21
Thread Starter
Hyperactive Member
There was a property called FORMAT in the textbox control for Access. I threw in the proper formatting and the problem went away.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|