Setting Default field value for telephone number. (1 Viewer)

Graham T

Registered User.
Local time
Today, 02:37
Joined
Mar 14, 2001
Messages
300
Is it possible to set up a default field value that will display 01457 for a telephone number field.

I have tried using the text and number data types, but it always removes the leading zero.

TIA

Graham
 

RobertQ

Registered User.
Local time
Today, 02:37
Joined
Jan 8, 2003
Messages
10
Hi Graham,

I tried this myself to create a prevalue to a field. This lead to nowhere.

To create leading zeroes you can use in the table definition of the field the format 000-00000 (in this case a department of a company which contain always the internal branch as "001" for example an then followed by the department no. "23450")and as input format 000\-00000.

If you use this field in a form the user has to input the information and the leading zeroes will be kept.

I hope this will help.

Kind regards
 

Graham T

Registered User.
Local time
Today, 02:37
Joined
Mar 14, 2001
Messages
300
Thanks for the reply Robert.

Although the user will still have to enter the dialling code.

What I am after is that the default dialling code be available, and they would then just have to enter the number.

Thanks

Graham
 

neileg

AWF VIP
Local time
Today, 02:37
Joined
Dec 4, 2002
Messages
5,975
Would it be inconvenient to hold the dialing code as a separate field? You could easily default your code in here. Leave the number itself for user input. You could link the dialing code to a table of codes to validate the input.

Even if you don't want to use a separate field, you could still set this up as a separate control on your form.
 

RobertQ

Registered User.
Local time
Today, 02:37
Joined
Jan 8, 2003
Messages
10
Hi,

is it possible to set the default number at an OnOpen event of the form?

Kind regards
 

Graham T

Registered User.
Local time
Today, 02:37
Joined
Mar 14, 2001
Messages
300
neileg

Thanks for the reply.

It would not be a problem to store this as another field, although again I still would not be able to set a default in the way that I would initially have thought possible.

I could create a new table as a look up table as such and store an ID associated with the code although again not the initial idea that I had.

I just thought that there must be a way to show a leading zero as a default field value !

Thanks

Graham
 

neileg

AWF VIP
Local time
Today, 02:37
Joined
Dec 4, 2002
Messages
5,975
Ah, right. Leading zero.

Well, you have to ask yourself what this dialing code represents, and how you are holding this. My guess is that you think it's a number, so the field you have defined is a number field. As others have said, it is possible to format a number to show one or more leading zeros, but the number will remain stored as just the number. Thus you enter 01457, this stores as 1457, but you can show it as 01457.

However, further thought will reveal that this code is not a number at all, but a code (see the answer is in the question!). So you will never have to use it as a number. So why store it as a number? Store it as text. Then you can default in the leading zero.

That still leaves you with a minor problem. If you use a field with a default value in a form, when you move to the control with this value in it, it is highlighted. When the user types in the value, the leading zero you have so thoughtfully supplied gets over written! You will have to use a bit of code to move the insert point after the zero. I don't know how to do this offhand.

You said:
I could create a new table as a look up table as such and store an ID associated with the code although again not the initial idea that I had.

Why would you want to store an ID? All I meant was to have a single field table holding a list of valid codes. Create your control for the code on your input form and attach a list box derived from your table. Since all your values would have a leading zero, this would force correct entry. I accept that this may not be what you want to do.
 

Users who are viewing this thread

Top Bottom