Hi -
First part-
What you are doing in the query I suggested is create a field which is
an expression that is based on other field(s) in the query, or the
table(s) on which the query is based.
In your case, the expression is based on one field, SSN, from one table.
Open the query in design view, and in a blank column, type this in the
"Field:" line (instead of a table field name):
MaskedSSN:"xxx-xx-" & Right([SSN],4)
The expression is the one you gave way back in the first post for the
masked SSN.
The 'MaskedSSN:' part is actually optional; what it does is give a
meaningful column header when you run the query. If you don't include
it, MS Access uses the default column header, 'Expr1'.
Now, because this is a Select query, it does not *change* anything in
the SSN field - it just displays it differently.
second Part:
I think what you are asking is - "Can a select query be used to update a
table?" The answer is yes, much of the time they can, and it is true
here. Basing your form on the query is the same as basing it on the table.
Your form will contain a control where you will type in the real SSN,
and it is bound to the SSN field in the query, which in turn is the SSN
field in the table. The Input Mask 'password' causes it to display as
'*********' on the screen, the value added to the table is the real SSN.
Another control on the form is bound to the MaskedSSN field in the
query, so it *displays* the masked version of the SSN, but because the
query field is an expression, it does not update the table. The form
control is automatically filled in by the query - you don't need to
change it.
Cheers!
John
Hi
I think I'm a bit flustered by all of this. I want to get it right before I
mess with it too much.
I should make a query that has all the fields that is on my form and tack
another in for the MaskedSSN. Confused by this: "MaskedSSN:"xxx-xx-" &
Right([SSN], MaskedSSN is the field name in the query." how do I write
this into the query?
Also, if I do this: " Set the control source of the masked SSN control to
the MaskedSSN field of the query, set the locked property to Yes, and set Tab
Stop to No. " Won't I lose the ssn number to the query and it not populate
the table?
Thanks,
Rae
:
Hi -
I was able replicate the behaviour you are seeing - it is the unbound
text box that is being replicated in all instances of the form. Any
changes I make to the bound controls (using the after update event of
the unbound box) are made only in the current record, i.e. the one the
cursor is in; but every time I change the unbound box, the changes are
made in all instances of the form.
With a little experimentation, I have a solution.
First:
Create a query containing all the fields from the table you are using,
plus an extra calculated field that masks the SSN:
MaskedSSN:"xxx-xx-" & Right([SSN], 4) MaskedSSN is the field name in
the query.
Next, change the record source of your form to the query, instead of the
table.
Make the SSN field on the form visible again, and set the inputmask
property to "Password" (no quotes)
Set the control source of the masked SSN control to the MaskedSSN field
of the query, set the locked property to Yes, and set Tab Stop to No.
Take the code to set the mask out of the On Lost Focus event of the SSN
- you don't need it because the query does it.
Give this a try.
John