Label/message inside textbox/combo box?

Angello Pimental

Registered User.
Local time
Today, 08:39
Joined
May 9, 2001
Messages
92
I have a form which is used to create a new record and input information.

I am wandering whether it is possible or not to have a mesage inside a text box stating: "Enter Name Here" or in a combo box stating: "Select Location".

And then once the user selects the text box/combo box and begins to enter information the message would then disappear.

My reasoning is to show the user exactly where to input the information, and what fields to fill in. As there are many fields, but the user only needs to provide limited information as the rest of the fields autopopulate based on the users selections and inputed info.

Any ideas, suggestions would be greatly appreciated.

Thnx, Angelo
 
I think a way round it would to size and place labels exactly over the input space on textbox/combo and when the field gets the focus hide the label...could be a lot of work though.

Ian
 
Hi Angelo,

i think you can do it by setting the default value of your boxes to whatever you want it to say eg "Enter Name" and then placing the below in the form's code somewhere
Code:
  Sub WipeDef() 
Dim strBox As String
strBox = Screen.ActiveControl.Name
    If StrComp(Chr(34) & Me(strBox).Value & Chr(34), Me(strBox).DefaultValue) = 0 Then
        Me(strBox) = ""
    End If
End Sub

then on each box that you want to have a default & wipe on just put WipeDef in its On Enter event.

To keep it clean you could then do the opposite on the way out of the box - ie if it is empty, put back the default
Code:
Sub ReplaceDef()
Dim strBox As String
strBox = Screen.ActiveControl.Name
    If Me(strBox) = "" Then
        Me(strBox) = Mid(Me(strBox).DefaultValue, 2, Len(Me(strBox).DefaultValue) - 2)
    End If
end sub

and then put ReplaceDef on the exit event of each box.

Thanks for the question - it had never occurred to me to do this before, i think i'll be using it. Anyway, hope it works for you,

Regards

Drew

PS - if anyone knows a better way of getting the default value without those pesky "" i'd love to know, thanks

[This message has been edited by KDg (edited 06-21-2001).]
 
Thank you Drew for your suggestion and code, I believe that it is the perfect answer.

I just have a problem with the default value "" as you mentioned below. I get the error "Field can't be a Zero length string".

I am working on the code now to get around that, I will keep you posted on how I do.

Thanks again,

Angelo
 
Well, I figured it out... no real stroke of genius needed.
If you are using combo boxes you don't need the code at all because the user must select a value.
And for the text boxes, you must go into the underlying table for the form, and set the Allow Zero-length Strings = Yes for the field the text box is based on.

Angelo
 

Users who are viewing this thread

Back
Top Bottom