Inserting static text into a field using a macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to insert 3 specific characters into a text field based upon part of
the text in another. I have tried to use SetValue, and RunSQL, but I can't
seem to get it to work right. If it says "MR & MRS" at the beginning of the
field, then I need to insert "M/M" in the prefix field. What's the best way
to do this?
 
What have you tried for SetValue? The expression would be something like
this for that action:
"M/M " & [NameOfTextboxControl]
 
In the ITEM field of the SetValue, I have "prefix" (quotes included) - that's
the only way it can even find the field.

In the EXPRESSION field, I have 'M/M' (quotes included).

No matter how I phrase it, it always tells me that I can't edit the field,
which I know I can manually.

As soon as I get this one figured out, I have about 10 more that I have to
do, but they should go really quick once I get this one done.

Thanks,

Kathie

Ken Snell said:
What have you tried for SetValue? The expression would be something like
this for that action:
"M/M " & [NameOfTextboxControl]
--

Ken Snell
<MS ACCESS MVP>

goodkat said:
I need to insert 3 specific characters into a text field based upon part of
the text in another. I have tried to use SetValue, and RunSQL, but I
can't
seem to get it to work right. If it says "MR & MRS" at the beginning of
the
field, then I need to insert "M/M" in the prefix field. What's the best
way
to do this?
 
You do not want to use " characters in the ITEM field. You want to use the
name of the CONTROL, not the FIELD, on the form.

Item: [Prefix]
Expression: ="M/M" & [Prefix]

--

Ken Snell
<MS ACCESS MVP>

goodkat said:
In the ITEM field of the SetValue, I have "prefix" (quotes included) -
that's
the only way it can even find the field.

In the EXPRESSION field, I have 'M/M' (quotes included).

No matter how I phrase it, it always tells me that I can't edit the field,
which I know I can manually.

As soon as I get this one figured out, I have about 10 more that I have to
do, but they should go really quick once I get this one done.

Thanks,

Kathie

Ken Snell said:
What have you tried for SetValue? The expression would be something like
this for that action:
"M/M " & [NameOfTextboxControl]
--

Ken Snell
<MS ACCESS MVP>

goodkat said:
I need to insert 3 specific characters into a text field based upon part
of
the text in another. I have tried to use SetValue, and RunSQL, but I
can't
seem to get it to work right. If it says "MR & MRS" at the beginning
of
the
field, then I need to insert "M/M" in the prefix field. What's the
best
way
to do this?
 
But I am using this to modify a table, so the control IS the field.

When I enter the text like this, it can't find the control prefix.

Am I going to have to create a form, and run the macro on the form, instead
of the table?

Ken Snell said:
You do not want to use " characters in the ITEM field. You want to use the
name of the CONTROL, not the FIELD, on the form.

Item: [Prefix]
Expression: ="M/M" & [Prefix]

--

Ken Snell
<MS ACCESS MVP>

goodkat said:
In the ITEM field of the SetValue, I have "prefix" (quotes included) -
that's
the only way it can even find the field.

In the EXPRESSION field, I have 'M/M' (quotes included).

No matter how I phrase it, it always tells me that I can't edit the field,
which I know I can manually.

As soon as I get this one figured out, I have about 10 more that I have to
do, but they should go really quick once I get this one done.

Thanks,

Kathie

Ken Snell said:
What have you tried for SetValue? The expression would be something like
this for that action:
"M/M " & [NameOfTextboxControl]
--

Ken Snell
<MS ACCESS MVP>

I need to insert 3 specific characters into a text field based upon part
of
the text in another. I have tried to use SetValue, and RunSQL, but I
can't
seem to get it to work right. If it says "MR & MRS" at the beginning
of
the
field, then I need to insert "M/M" in the prefix field. What's the
best
way
to do this?
 
SetValue cannot be used to edit the contents of a table's field. You can use
it to modify the contents of a control on a report, though.

One should not be entering/editing data directly in a table.

--

Ken Snell
<MS ACCESS MVP>

goodkat said:
But I am using this to modify a table, so the control IS the field.

When I enter the text like this, it can't find the control prefix.

Am I going to have to create a form, and run the macro on the form,
instead
of the table?

Ken Snell said:
You do not want to use " characters in the ITEM field. You want to use
the
name of the CONTROL, not the FIELD, on the form.

Item: [Prefix]
Expression: ="M/M" & [Prefix]

--

Ken Snell
<MS ACCESS MVP>

goodkat said:
In the ITEM field of the SetValue, I have "prefix" (quotes included) -
that's
the only way it can even find the field.

In the EXPRESSION field, I have 'M/M' (quotes included).

No matter how I phrase it, it always tells me that I can't edit the
field,
which I know I can manually.

As soon as I get this one figured out, I have about 10 more that I have
to
do, but they should go really quick once I get this one done.

Thanks,

Kathie

:

What have you tried for SetValue? The expression would be something
like
this for that action:
"M/M " & [NameOfTextboxControl]
--

Ken Snell
<MS ACCESS MVP>

I need to insert 3 specific characters into a text field based upon
part
of
the text in another. I have tried to use SetValue, and RunSQL, but
I
can't
seem to get it to work right. If it says "MR & MRS" at the
beginning
of
the
field, then I need to insert "M/M" in the prefix field. What's the
best
way
to do this?
 
Back
Top