text format? Not Really!

  • Thread starter Thread starter miss031
  • Start date Start date
M

miss031

Why, when I make an entry into a form field bound to a table source that is
Tex format, does it automatically calculate what I entered?

I need to enter driver's licence numbers, and here, they have dashes in
them, but instead of "1100-100", it will store "1000", calculating the first
number *minus* the second number. I don't think I can use an input mask,
because the numbers vary in size.
 
Hi,
I have made a new table with a text field, I type in 1100-100 and it stays
as 1100-100. I can close the form and open it again and it is still showing
1100-100

Jeanette Cunningham
 
Where exactly is this field "formatted" as text? In the table Design View,
what is the datatype for the field? This is very curious behavior; even if
the field were defined as numeric, entering 11000-100 should pop an error
message, as this isn't a valid number, rather than performing a calculation.
Truly weird behavior usually is the result of corruption.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
miss031 said:
Why, when I make an entry into a form field bound to a table source that is
Tex format, does it automatically calculate what I entered?

I need to enter driver's licence numbers, and here, they have dashes in
them, but instead of "1100-100", it will store "1000", calculating the first
number *minus* the second number. I don't think I can use an input mask,
because the numbers vary in size.


That is not normal behavior for a text box bound to a field
in a table. To get that effect, you would have to have
something in the text box's event procedures to evaluate the
text as an expression. Possibilities include using the Eval
function or assigning the text to the text box's
DefaultValue property for the next new record.

Or maybe you were working in the form's design view and
typed that into the text box's DefaultValue property.
 
I do have code that assigns a default value, because the form is based on a
query, and the inputs of the combos are used for update/append queries., so
upon opening, the combos are assinged as a default value, tehir matching
fields from the query.

Would setting the .DefaultValue cause this bevahiour? I can't imagine what
else it could be!
 
I don't know what you have so I can't say if it caused the
effect you are asking about. However, the reason I
mentioned the DefaultValue property as something to
investigate is because the string in the property is
evaluated as an expression when it is used on a new record.

The standard syntax to assign a text value to the
DefaultValue property is:
Me.somecontrol.DefaultValue = """" & x & """"
where x is some variable, control or field name. The
property will then contain "1100-100" (including the
surrounding " marks). When the default is applied to the
control on a new record, the **expression** "1100-100" will
evaluate to the text string 1100-100 (without the " marks).

I suspect that what you did was something like:
Me.somecontrol.DefaultValue = x
so the property then contains 1100-100 (without " marks).
When this default is applied, the expression 1100-100 is
evaluated and the result is 1000.

This can get even more confusing when setting the
DefaultValue to a date where # signs are also needed. And,
of course, none of this confusion arises when setting the
DefaultValue to a number, because a number as an expression
just evaluates to itself.
 
Thank you very much. Exactly what I was looking for!

Marshall Barton said:
I don't know what you have so I can't say if it caused the
effect you are asking about. However, the reason I
mentioned the DefaultValue property as something to
investigate is because the string in the property is
evaluated as an expression when it is used on a new record.

The standard syntax to assign a text value to the
DefaultValue property is:
Me.somecontrol.DefaultValue = """" & x & """"
where x is some variable, control or field name. The
property will then contain "1100-100" (including the
surrounding " marks). When the default is applied to the
control on a new record, the **expression** "1100-100" will
evaluate to the text string 1100-100 (without the " marks).

I suspect that what you did was something like:
Me.somecontrol.DefaultValue = x
so the property then contains 1100-100 (without " marks).
When this default is applied, the expression 1100-100 is
evaluated and the result is 1000.

This can get even more confusing when setting the
DefaultValue to a date where # signs are also needed. And,
of course, none of this confusion arises when setting the
DefaultValue to a number, because a number as an expression
just evaluates to itself.
--
Marsh
MVP [MS Access]

I do have code that assigns a default value, because the form is based on a
query, and the inputs of the combos are used for update/append queries., so
upon opening, the combos are assinged as a default value, tehir matching
fields from the query.

Would setting the .DefaultValue cause this bevahiour? I can't imagine what
else it could be!
 
Back
Top