Formatting a Combo box

M

Mike

If i'm using a combo box to lookup records based on a SSN, for example, and
I store the SSN's in the table as a pure number (123456789) - Is there a way
to get the combo box to display the numbers in their input mask format
(123-45-6789)? An output mask, so to speak... :)
 
P

Pat Hartman

Create a query that selects the SSN twice. Format the second instance to
include the dashes. In your combo, bind the first column and hide it. The
users will only see the formatted number but your table will store the
unformatted value.
 
M

Mike

Well, the query does show the values with the separators. Every instance
i've selected for the value from the field to every text box it's displayed
in has had the input masking but told the control to save it as pure
numbers. Maybe a straight reference of the query will do it?
 
M

Mike

Maybe it's just the end of a long week, but i've got to be missing
something. I've tried that and i've tried using things like 'currency' and
'decimal' etc from the Format options and it still returns 123456789...
 
J

John W. Vinson

Maybe it's just the end of a long week, but i've got to be missing
something. I've tried that and i've tried using things like 'currency' and
'decimal' etc from the Format options and it still returns 123456789...

Don't choose any of the preloaded options.

Instead, use the keyboard to type Klatuu's literal text string

"000\-000\-0000"

into the Format property of the control.

John W. Vinson [MVP]
 
M

Mike

I did. It didn't work. When that didn't work, i tried other presets for
kicks to see if anything would work. (They didn't) I'm wondering if i have
to recreate the control or something.
 
J

John W. Vinson

I did. It didn't work. When that didn't work, i tried other presets for
kicks to see if anything would work. (They didn't) I'm wondering if i have
to recreate the control or something.

What are the properties of the combo box?

Rowsource: fieldnames, datatypes, a record or two of sample data for the first
nonzero width column
Control Source: fieldname, datatype, sample data
Bound Column
ColumnWidths

John W. Vinson [MVP]
 
M

Mike

Rowsource: SELECT [customers].[CustID], [customers].[Phone] FROM customers;
Column Widths: 0";1"
Bound Column: 1
Control Source: Blank

I think that's all of them. I guess it got changed up, it's doing this on
phone number not ssn. Either way, no formating i've tried does anything to
the combo box. This field is used to look up a client to see if they exist
in the db, if not, there is code to create a new record based on that phone
number. Could the code portion be messing with it?
 
M

Mike

Additionally, if you select a record from the list, the record selected
shows the proper format in the main area of the combo box. The area i'm
specifically referring to is the 8 rows that appear below the box when you
click on the down arrow to look them up throw the list. Those are the ones
that just say 123456789.
Mike said:
Rowsource: SELECT [customers].[CustID], [customers].[Phone] FROM
customers;
Column Widths: 0";1"
Bound Column: 1
Control Source: Blank

I think that's all of them. I guess it got changed up, it's doing this on
phone number not ssn. Either way, no formating i've tried does anything to
the combo box. This field is used to look up a client to see if they exist
in the db, if not, there is code to create a new record based on that
phone number. Could the code portion be messing with it?




John W. Vinson said:
What are the properties of the combo box?

Rowsource: fieldnames, datatypes, a record or two of sample data for the
first
nonzero width column
Control Source: fieldname, datatype, sample data
Bound Column
ColumnWidths

John W. Vinson [MVP]
 
J

John W. Vinson

I think that's all of them. I guess it got changed up, it's doing this on
phone number not ssn. Either way, no formating i've tried does anything to
the combo box. This field is used to look up a client to see if they exist
in the db, if not, there is code to create a new record based on that phone
number. Could the code portion be messing with it?

I guess I'd suggest using a query to calculate the formatted number, and hide
but store the unformatted number:

Rowsource: SELECT [customers].[CustID], [customers].[Phone],
Format([customers].[Phone], "\(@@@\) @@@\-@@@@") AS ShowPhone FROM customers;
Column Widths: 0";0";1"
Bound Column: 1
Control Source: Blank


John W. Vinson [MVP]
 
M

Mike

THANK YOU!!

Putting it all the Rowsource like that works perfectly! And it makes perfect
sense to boot :)

John W. Vinson said:
I think that's all of them. I guess it got changed up, it's doing this on
phone number not ssn. Either way, no formating i've tried does anything to
the combo box. This field is used to look up a client to see if they exist
in the db, if not, there is code to create a new record based on that
phone
number. Could the code portion be messing with it?

I guess I'd suggest using a query to calculate the formatted number, and
hide
but store the unformatted number:

Rowsource: SELECT [customers].[CustID], [customers].[Phone],
Format([customers].[Phone], "\(@@@\) @@@\-@@@@") AS ShowPhone FROM
customers;
Column Widths: 0";0";1"
Bound Column: 1
Control Source: Blank


John W. Vinson [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top