Default Value

S

Sash

I have a form and I'm trying to make the default value of one field equal to
a combination of two other fields. On the Data properties of CMD field, I
have the following on Default Value:

=([RevCtr]) & Right([SimItem], 4)

Why isn't this working? All fields are text fields.
 
K

KARL DEWEY

It is difficult to say with out knowing what you are geeting as a result.
I assume that RevCtr and SimItem are field names.
Give an example of the data in them and what you get that 'isn't working.'
 
S

Sash

Yes they are fields.

Example:
RevCtr 234
SimItem 12345

Result I want:
2342345

However, the field remains blank. It's not displaying anything. I do
something similar on a different form and it works perfed.

KARL DEWEY said:
It is difficult to say with out knowing what you are geeting as a result.
I assume that RevCtr and SimItem are field names.
Give an example of the data in them and what you get that 'isn't working.'
--
KARL DEWEY
Build a little - Test a little


Sash said:
I have a form and I'm trying to make the default value of one field equal to
a combination of two other fields. On the Data properties of CMD field, I
have the following on Default Value:

=([RevCtr]) & Right([SimItem], 4)

Why isn't this working? All fields are text fields.
 
L

Linq Adams via AccessMonster.com

"However, the field remains blank. It's not displaying anything."

The Default Value of a field is only valid when you go to a ***new record***,
which means it has to be set ***before*** a new record is invoked. In other
words, you can't enter a value in RevCtr and SimItem and set CMD.DefaultValue
= ([RevCtr]) & Right([SimItem], 4) and think that CMD on ***this same
record*** will then be populated from this formula, which is what it sounds
like you expect.. You'd have to use the AfterUpdate events of your two
"supplying" fields, as it were.

Private Sub RevCtr_AfterUpdate()
If Not IsNull(Me.SimItem) Then Me.CMD = Right(Me.SimItem, 4) & Me.RevCtr
End Sub

Private Sub SimItem_AfterUpdate()
If Not IsNull(Me.RevCtr) Then Me.CMD = Right(Me.SimItem, 4) & Me.RevCtr
End Sub

When both of the fields SimItem and RevCtr are populated, and you move from
the second one's textbox, CMD will be populated. Is this your intent?

As an alternative, if your form were based on a query, you could use a
calculated field in the query to do the same thing.

CMD: Right([SimItem], 4) & [RevCtr]

Then set the Control Source of your textbox on your form to this calculated
field.
Try this.
=([RevCtr]) &""& Right([SimItem],4)
I have a form and I'm trying to make the default value of one field equal to
a combination of two other fields. On the Data properties of CMD field, I
[quoted text clipped - 3 lines]
Why isn't this working? All fields are text fields.
 
L

Linq Adams via AccessMonster.com

Sorry, forgot to add:

Using the first method, to use CMD on a Report, you'd have to use an unbound
textbox and assign it's Control Source as

= ([RevCtr]) & Right([SimItem], 4)

If you use the second method, calculating it in the query, you'd simply refer
to the calculated field, CMD.
 
Top