Using a macro to insert text into a field

G

Guest

I've read the help section on SetValue. I've read the books I have, but
still can't get this to work. Clearly I don't have the expression syntax
correct. How do I (what is the syntax) insert text into a field, on a form,
using the the SetValue action. I also want the current value of the field to
be overwritten, not just added to. Any help will be very much appreciated.

Thank you in advance
 
K

Ken Snell \(MVP\)

General answer is an expression similar to this as the Expression argument:

"Here Is My Text String"
 
G

Guest

I appreciate the feedback, but there must be something between the the
designation of the item, and the string. I've tried the following:

[Forms]![formname]![field/control name] & "My Text String"
I've used = in place of the &
When I just put a space there, I get an error that says Access can't parse
it. I'm at a loss. Pardon my frustration, but I will never understand why
this app makes such a simple thing so complex.

Thanks,

Legler
 
K

Ken Snell \(MVP\)

For a macro's SetValue action, there are two arguments. Expression is the
actual value to be written into the control. Item is the name of the
control.

If you're running the macro from the form that contains the control, then
you don't need to use all the Forms!FormName stuff; you can just use the
control name by itself.
[NameOfControlOnFormThatCallsTheMacro]

Otherwise, the Item should be this syntax:
[Forms]![NameOfForm]![NameOfControl]

You do not put the text expression into the Item argument; that goes in the
Expression argument. For example, suppose I want to write the text string "I
Have A Plan" into the txtPlans control on the form MyPlanningForm. Here are
the appropriate arguments for the SetValue action:
Item: [Forms]![MyPlanningForm]![txtPlans]
Expression: "I Have A Plan"
--

Ken Snell
<MS ACCESS MVP>




Legler said:
I appreciate the feedback, but there must be something between the the
designation of the item, and the string. I've tried the following:

[Forms]![formname]![field/control name] & "My Text String"
I've used = in place of the &
When I just put a space there, I get an error that says Access can't parse
it. I'm at a loss. Pardon my frustration, but I will never understand
why
this app makes such a simple thing so complex.

Thanks,

Legler

Ken Snell (MVP) said:
General answer is an expression similar to this as the Expression
argument:

"Here Is My Text String"
 
G

Guest

Thanks. I must have misunderstood the instructions in the help section. I
appreciate the help.

Legler

Ken Snell (MVP) said:
For a macro's SetValue action, there are two arguments. Expression is the
actual value to be written into the control. Item is the name of the
control.

If you're running the macro from the form that contains the control, then
you don't need to use all the Forms!FormName stuff; you can just use the
control name by itself.
[NameOfControlOnFormThatCallsTheMacro]

Otherwise, the Item should be this syntax:
[Forms]![NameOfForm]![NameOfControl]

You do not put the text expression into the Item argument; that goes in the
Expression argument. For example, suppose I want to write the text string "I
Have A Plan" into the txtPlans control on the form MyPlanningForm. Here are
the appropriate arguments for the SetValue action:
Item: [Forms]![MyPlanningForm]![txtPlans]
Expression: "I Have A Plan"
--

Ken Snell
<MS ACCESS MVP>




Legler said:
I appreciate the feedback, but there must be something between the the
designation of the item, and the string. I've tried the following:

[Forms]![formname]![field/control name] & "My Text String"
I've used = in place of the &
When I just put a space there, I get an error that says Access can't parse
it. I'm at a loss. Pardon my frustration, but I will never understand
why
this app makes such a simple thing so complex.

Thanks,

Legler

Ken Snell (MVP) said:
General answer is an expression similar to this as the Expression
argument:

"Here Is My Text String"


--

Ken Snell
<MS ACCESS MVP>


I've read the help section on SetValue. I've read the books I have,
but
still can't get this to work. Clearly I don't have the expression
syntax
correct. How do I (what is the syntax) insert text into a field, on a
form,
using the the SetValue action. I also want the current value of the
field
to
be overwritten, not just added to. Any help will be very much
appreciated.

Thank you in advance
 
E

Elliot J

Ken Snell (MVP) said:
For a macro's SetValue action, there are two arguments. Expression is the
actual value to be written into the control. Item is the name of the
control.

If you're running the macro from the form that contains the control, then
you don't need to use all the Forms!FormName stuff; you can just use the
control name by itself.
[NameOfControlOnFormThatCallsTheMacro]

Otherwise, the Item should be this syntax:
[Forms]![NameOfForm]![NameOfControl]

You do not put the text expression into the Item argument; that goes in
the Expression argument. For example, suppose I want to write the text
string "I Have A Plan" into the txtPlans control on the form
MyPlanningForm. Here are the appropriate arguments for the SetValue
action:
Item: [Forms]![MyPlanningForm]![txtPlans]
Expression: "I Have A Plan"
--

Ken Snell
<MS ACCESS MVP>




Legler said:
I appreciate the feedback, but there must be something between the the
designation of the item, and the string. I've tried the following:

[Forms]![formname]![field/control name] & "My Text String"
I've used = in place of the &
When I just put a space there, I get an error that says Access can't
parse
it. I'm at a loss. Pardon my frustration, but I will never understand
why
this app makes such a simple thing so complex.

Thanks,

Legler

Ken Snell (MVP) said:
General answer is an expression similar to this as the Expression
argument:

"Here Is My Text String"


--

Ken Snell
<MS ACCESS MVP>


I've read the help section on SetValue. I've read the books I have,
but
still can't get this to work. Clearly I don't have the expression
syntax
correct. How do I (what is the syntax) insert text into a field, on a
form,
using the the SetValue action. I also want the current value of the
field
to
be overwritten, not just added to. Any help will be very much
appreciated.

Thank you in advance

Sorry for hijacking this thread but I am new to Access and just trying to
learn my way around it.

You are discussing the SetValue 'Action' within macros. But when I look at
the drop-down list of available Actions, I see no such option. The nearest
seems to be SetMenuItem, SetProperty or SetTempVar.

What am I missing?

I'm using Access 2007.

Thanks.
 
E

Elliot J

Elliot J said:
Ken Snell (MVP) said:
For a macro's SetValue action, there are two arguments. Expression is the
actual value to be written into the control. Item is the name of the
control.

If you're running the macro from the form that contains the control, then
you don't need to use all the Forms!FormName stuff; you can just use the
control name by itself.
[NameOfControlOnFormThatCallsTheMacro]

Otherwise, the Item should be this syntax:
[Forms]![NameOfForm]![NameOfControl]

You do not put the text expression into the Item argument; that goes in
the Expression argument. For example, suppose I want to write the text
string "I Have A Plan" into the txtPlans control on the form
MyPlanningForm. Here are the appropriate arguments for the SetValue
action:
Item: [Forms]![MyPlanningForm]![txtPlans]
Expression: "I Have A Plan"
--

Ken Snell
<MS ACCESS MVP>




Legler said:
I appreciate the feedback, but there must be something between the the
designation of the item, and the string. I've tried the following:

[Forms]![formname]![field/control name] & "My Text String"
I've used = in place of the &
When I just put a space there, I get an error that says Access can't
parse
it. I'm at a loss. Pardon my frustration, but I will never understand
why
this app makes such a simple thing so complex.

Thanks,

Legler

:

General answer is an expression similar to this as the Expression
argument:

"Here Is My Text String"


--

Ken Snell
<MS ACCESS MVP>


I've read the help section on SetValue. I've read the books I have,
but
still can't get this to work. Clearly I don't have the expression
syntax
correct. How do I (what is the syntax) insert text into a field, on
a
form,
using the the SetValue action. I also want the current value of the
field
to
be overwritten, not just added to. Any help will be very much
appreciated.

Thank you in advance

Sorry for hijacking this thread but I am new to Access and just trying to
learn my way around it.

You are discussing the SetValue 'Action' within macros. But when I look at
the drop-down list of available Actions, I see no such option. The nearest
seems to be SetMenuItem, SetProperty or SetTempVar.

What am I missing?

I'm using Access 2007.

Thanks.

Nevermind, I realised what was wrong. I needed to enable the viewing of all
possible options in the toolbar.
 

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