Hiding part of a text fields input

User avatar
teachesms
2StarLounger
Posts: 170
Joined: 05 Feb 2010, 18:04
Location: Jacksonville, NC

Hiding part of a text fields input

Post by teachesms »

I have another question with Access tonight (2 right in a row), I'm on a roll.

Is there a way to hide a portion of a data fields input...example I type in 9 Social Security Numbers into a text field. I only want the last 4 to be visible. Is it possible? I know you can password a whole field and ********* will appear, but I DO want the last 4 to show.

I'm thinking there isn't a way, but hey...I got to ask.
If you can't convince them, confuse them - Harry S. Truman

Nannette

User avatar
Claude
cheese lizard
Posts: 6241
Joined: 16 Jan 2010, 00:14
Location: Sydney Australia

Re: Hiding part of a text fields input

Post by Claude »

I'm by no means an Access expert, but, why don't you have two fields next to each other: one 5 character field with password property, then a 4 character normal text field, then concatenate the two together and store in another field not shown on the form...
Cheers, Claude.

User avatar
HansV
Administrator
Posts: 78524
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Hiding part of a text fields input

Post by HansV »

Claude's suggestion is the easiest workaround.

In the attached sample database, a more complicated approach is demonstrated; it may be more work than it's worth.
TestInput.zip
Two text boxes are used:
One is bound to the SSN field, and is usually hidden.
The other is a calculated control that displays something like *****1234 where 1234 are the last 4 digits of the SSN. This one is usually visible, but locked.
The text boxes have the same size and position.
Next to the text boxes is a command button "Edit". When the user clicks this button, the calculated text box is hidden and the bound text box shown.
In the After Update event of the bound text box, the calculated text box is shown again and the bound text box hidden.
The On Current event of the form shows the bound text box in a new record, and the calculated one in existing records.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15636
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Hiding part of a text fields input

Post by ChrisGreaves »

HansV wrote:In the attached sample database,
Neat!
And if I've done my sums right, only 17 lines of code.
There's nothing heavier than an empty water bottle

User avatar
teachesms
2StarLounger
Posts: 170
Joined: 05 Feb 2010, 18:04
Location: Jacksonville, NC

Re: Hiding part of a text fields input

Post by teachesms »

I will work with these recommendations today. Thank you again everyone, as the advice you give is "always sage"...

I so depend on you!

:)
If you can't convince them, confuse them - Harry S. Truman

Nannette

User avatar
teachesms
2StarLounger
Posts: 170
Joined: 05 Feb 2010, 18:04
Location: Jacksonville, NC

Re: Hiding part of a text fields input

Post by teachesms »

Hans your answer seemed to do the trick for the student in my class who needed the answer. He is now a logged in user at Eileens so he can start asking questions on his own. Your the best resource I can give to any student in any class that I instruct. You guys are great! We thank all of you for all your input and solving his question. He felt that it was an easy work around and not difficult at all. :)
If you can't convince them, confuse them - Harry S. Truman

Nannette

Stew
StarLounger
Posts: 76
Joined: 14 Jul 2010, 19:35

Re: Hiding part of a text fields input

Post by Stew »

I will happily admit that I am that student. Teachesms has introduced me to this site, and I will stay with it. Thanks for your help. The if statement forces a limit on the show was a very interesting idea. I must admit that was a very creative idea of limiting the string. That has opened my eyes to some other ideas I have. Thanks. I'm sure I will post alot more on here.

Stew
StarLounger
Posts: 76
Joined: 14 Jul 2010, 19:35

Re: Hiding part of a text fields input

Post by Stew »

I have encountered a question relating to this previous topic I am hoping I could get answered. While this works for forms, I am trying to only show the last 4 in datasheets, reports, and/or queries. Can I use the same type of code to use this in those situations? I would like to allow a user to print a report with the last 4 of a SSN, hopefully keeping the input as a full 9 digit SSN.

User avatar
HansV
Administrator
Posts: 78524
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Hiding part of a text fields input

Post by HansV »

You can't do this in a datasheet form or query. You could have two columns side by side, one with the full SSN and one with the display value.

You can do it in a continuous form, and if you wish you cna make a continuous form look like a datasheet.

A report isn't used for input, so you only need a text box that displays the last 4 digits, you don't need a text box that contains the full SSN there.
Best wishes,
Hans

Stew
StarLounger
Posts: 76
Joined: 14 Jul 2010, 19:35

Re: Hiding part of a text fields input

Post by Stew »

I'm not worried about input for the last 4. I am trying to set it up inside the dynamic report that we set up in this thread: http://eileenslounge.com/viewtopic.php?f=29&t=2931 so that the SSN field will report the last 4 if possible.

User avatar
HansV
Administrator
Posts: 78524
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Hiding part of a text fields input

Post by HansV »

I'd create a query qryMain based on tblMain that returns all the fields from tblMain plus a calculated column that displays the last 4 digits of the SSN.
Then use qryMain instead of tblMain in the code from the other thread.
Best wishes,
Hans