Default value display problem

A

Angi

If any of you have been reading my posts, you should be able to
visualize my whole db by now <g>. I have a ContactSubForm on my
MainForm. I also have a cmdAddContact btn on the main form. This
opens the ContactMain form. I've recently changed the coding so that
the default value of the phone # equals the company's #. It works
great, input mask and all, but it's not saving with the input mask when
it should be. It will only save if I type in the field (same number or
not). So, on my ContactSubForm, for the records where the default was
accepted, all the nos. run together (ie:1115552323). EVERYTHING
(tables, forms, subforms) has the same mask and the mask is set to save
format to the table.

How can I keep using the default value but make it save with the input
mask?
 
D

DebbieG

My best guess is that you need to store the symbols with the data. I think you do this by having a 0 in that position (;0), like
this:

!(999) 000-0000;0;_

HTH,
Debbie

| If any of you have been reading my posts, you should be able to
| visualize my whole db by now <g>. I have a ContactSubForm on my
| MainForm. I also have a cmdAddContact btn on the main form. This
| opens the ContactMain form. I've recently changed the coding so that
| the default value of the phone # equals the company's #. It works
| great, input mask and all, but it's not saving with the input mask when
| it should be. It will only save if I type in the field (same number or
| not). So, on my ContactSubForm, for the records where the default was
| accepted, all the nos. run together (ie:1115552323). EVERYTHING
| (tables, forms, subforms) has the same mask and the mask is set to save
| format to the table.
|
| How can I keep using the default value but make it save with the input
| mask?
|
 
A

Angi

Debbie,
Thanks for the reply. That is what I'm doing. In everything like I
said. The tables, forms and subforms.

Thanks!
 
D

DebbieG

Sorry, I read it again and noticed that you did say that.

I had a database where I having the same problem with an SSN. Now that I think more about it, I think in the table I stored it
without the symbols and then just formatted it whenever I used it in forms, comboboxes, and reports. I'll look a little further to
see how I got it to work. I just remember it causing me hours of trying to come up with the right combination.

HTH,
Debbie


| Debbie,
| Thanks for the reply. That is what I'm doing. In everything like I
| said. The tables, forms and subforms.
|
| Thanks!
|
 
A

Angi

Debbie,
Not a problem. I saved the format in the table for exactly the reason
you said...I don't want to have to format it everywhere else. I use
these numbers too frequently to do all that. I like the easy way! :)


That's why I can't figure out why the default isn't staying that way,
when it should carry over like that. Thanks for trying to help me!

Regards,
Ang
 
J

John Nurick

I can't, because I never use input masks, partly because of this sort of
nagging problem, and partly because they make it impossible to handle
international variations.

Instead, I'd store the value complete with ()- etc., and use a
validation rule (if possible) and/or validation code in the form
control's BeforeUpdate event to ensure that the data fits the required
pattern.
 
D

DebbieG

You stated "I've recently changed the coding so that the default value of the
phone # equals the company's #." Is the phone # coming from a combo box?
Please post the code you're using to do this.

Debbie


| Debbie,
| Not a problem. I saved the format in the table for exactly the reason
| you said...I don't want to have to format it everywhere else. I use
| these numbers too frequently to do all that. I like the easy way! :)
|
|
| That's why I can't figure out why the default isn't staying that way,
| when it should carry over like that. Thanks for trying to help me!
|
| Regards,
| Ang
|
 
A

Angi

First, I am saving the complete mask value in the table. (111)
222-3333.
This is my input mask in the table: !\(999") "000\-0000;0;_

Second, no this is not coming from a combo box. It's a bound text box.

If Me.Phone = "" Then
Me.Phone.DefaultValue = Forms!companymain.Phone
End If

Like I said, it works, but it's not keeping the format. Here's the
weird thing, I've double and triple checked whether or not it's saving
in the table...it is. I've set my form up the same way, just in case.
When I put it on a report to view, the mask isn't there unless I make
it look that way by changing the input mask of the field. Why's that
if it's supposed to save in the table?

The typing in of the number, is not the problem. I've run a few other
tests and it's ok as long as the input mask is in the field. My
problem seems to lie in the fact that I'm trying concatenate the field
with another and it's losing it's mask. I guess the only way I'm gonna
get it back is create it with Left, Right, and Mid. What fun! I
thought I as solving that problem by saving it in the table like that.
 
D

DebbieG

Here's my last shot:

If Me.Phone = "" Then
Format(Me.Phone.DefaultValue, "(@@@) @@@-@@@@") =
Forms!companymain.Phone
End If

or put (@@@) @@@-@@@@ as the Format in the Phone field on your subform.

You didn't say where this code is ... Form_Current? Are you really wanting to
change the Default Value of the field or just enter the CompanyMain.Phone into
the Subform's Phone field of a new record? If so, the Phone would always be
blank and you can just

Me.Phone = Forms!companymain.Phone

In your table, is the size of the Phone 14 to accommodate for the numbers,
parentheses, dash, and space?

Since you have the InputMask everywhere, have you tried removing it from the
table and just using it when displaying it in forms and reports?

That's all I can think of,
Debbie


| First, I am saving the complete mask value in the table. (111)
| 222-3333.
| This is my input mask in the table: !\(999") "000\-0000;0;_
|
| Second, no this is not coming from a combo box. It's a bound text box.
|
| If Me.Phone = "" Then
| Me.Phone.DefaultValue = Forms!companymain.Phone
| End If
|
| Like I said, it works, but it's not keeping the format. Here's the
| weird thing, I've double and triple checked whether or not it's saving
| in the table...it is. I've set my form up the same way, just in case.
| When I put it on a report to view, the mask isn't there unless I make
| it look that way by changing the input mask of the field. Why's that
| if it's supposed to save in the table?
|
| The typing in of the number, is not the problem. I've run a few other
| tests and it's ok as long as the input mask is in the field. My
| problem seems to lie in the fact that I'm trying concatenate the field
| with another and it's losing it's mask. I guess the only way I'm gonna
| get it back is create it with Left, Right, and Mid. What fun! I
| thought I as solving that problem by saving it in the table like that.
|
 
A

Angi

Debbie,
Thanks for the reply.
This code is in my Form_Open event along with openargs, etc. As far as
why I'm not using the me.phone=forms!.... is because I keep getting the
error: You can't assign a value to this object. If I move it to the
Form_Current event, it doesn't do anything...blank. As long as I keep
it in the Form_Open event with .defaultvalue, it puts the number in.

In the previous post I said, the typing in of the number, is not the
problem. That it was: My problem seems to lie in the fact that I'm
trying concatenate the field
with another and it's losing it's mask. Not the case. As long as I
type it, the concatenting works fine (mask and all). It's only when I
don't type anything, accepting the default, that it doesn't. This is
driving me crazy!!!! I don't understand why the form/field is
differentiating between putting a value in there and typing a value in
there. I guess because of the InputMask and there's technically no
input (?).

Soooo...is there a way to make the field "think" I'm inputting it
without actually doing it? I hope this helps everyone help me. Thanks
everyone!
 

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