Command Buttons

J

jimswinder

I am trying to create a button that when clicked will take text from a field
in a form and put it into a field in the table from where the form was
created. Is this possible?
I have tried using the Expression Builder (=[Combo51] = [Combo42] )...but
the text does not get into the table field. Thoughts??
 
R

Ronald Roberts

jimswinder said:
I am trying to create a button that when clicked will take text from a field
in a form and put it into a field in the table from where the form was
created. Is this possible?
I have tried using the Expression Builder (=[Combo51] = [Combo42] )...but
the text does not get into the table field. Thoughts??

Not sure I understand what you want.
If the form is bound, which means the form has a record source.
And if the controls on the form are bound, which means they have a
control source, then the table will be updated when the user moves to
another record or closes the form.

If you are trying to update a calculated field, don't.
This will lead to other data problems in the future. All calculated
fields or values can be recalculated in a form in an unbound control
or in a query for a report.

Ron
 
A

Al Camp

Jim,
If a text control, on a form, is "bound" to a field in your table, any
data entered into that text control will be stored in that field of your
table.
"Bound" means that the ControlSource property of that text control is set
to the appropriate field name from your table
If that value must be passed to another control on the form, and saved in
the table, then that second field must be bound also.
Say you had a field called FirstName, bound to [FirstName] in your
table... and another field on the form called Other, bound to field [Other]
in your table.
In order to pass that value from FirstName to Other, use the AfterUpdate
event of FirstName with this code...
Me.Other = Me.FirstName

A text control must be bound to a field in your table (ControlSource) in
order to save the value entered into it.
A text control with a (ControlSource) calculation such as =FirstName will
display the FirstName value, but will not store it.

hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions
 
J

jimswinder

Perhaps I should back up a step...
lets say I have 4 fields (all text fields). Field 1 has "I", Field 2 has
"see", Field 3 "red" and Field 4 "spots." What I want to do is combine the
four fields and put the combined text "I see red spots" into a fifh field in
the table. I have no problem combining the fields within a form...but can't
get the new text into the fifth table field.

PS..thanks for fast response!!!! :)

Ronald Roberts said:
jimswinder said:
I am trying to create a button that when clicked will take text from a field
in a form and put it into a field in the table from where the form was
created. Is this possible?
I have tried using the Expression Builder (=[Combo51] = [Combo42] )...but
the text does not get into the table field. Thoughts??

Not sure I understand what you want.
If the form is bound, which means the form has a record source.
And if the controls on the form are bound, which means they have a
control source, then the table will be updated when the user moves to
another record or closes the form.

If you are trying to update a calculated field, don't.
This will lead to other data problems in the future. All calculated
fields or values can be recalculated in a form in an unbound control
or in a query for a report.

Ron
 
J

jimswinder

Hey Al...

Tried it..it didn't work...perhaps I am not doing it right. Could you look
at my reply to Ronald...is what you tried to tell me get the result I am
looking for?

PS: Thanks for your quick response also!!!

Al Camp said:
Jim,
If a text control, on a form, is "bound" to a field in your table, any
data entered into that text control will be stored in that field of your
table.
"Bound" means that the ControlSource property of that text control is set
to the appropriate field name from your table
If that value must be passed to another control on the form, and saved in
the table, then that second field must be bound also.
Say you had a field called FirstName, bound to [FirstName] in your
table... and another field on the form called Other, bound to field [Other]
in your table.
In order to pass that value from FirstName to Other, use the AfterUpdate
event of FirstName with this code...
Me.Other = Me.FirstName

A text control must be bound to a field in your table (ControlSource) in
order to save the value entered into it.
A text control with a (ControlSource) calculation such as =FirstName will
display the FirstName value, but will not store it.

hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions


jimswinder said:
I am trying to create a button that when clicked will take text from a
field
in a form and put it into a field in the table from where the form was
created. Is this possible?
I have tried using the Expression Builder (=[Combo51] = [Combo42] )...but
the text does not get into the table field. Thoughts??
 
J

jimswinder

Al:

Does the Me in Me.Other = Me.FirstName equal the Table Name?

Al Camp said:
Jim,
If a text control, on a form, is "bound" to a field in your table, any
data entered into that text control will be stored in that field of your
table.
"Bound" means that the ControlSource property of that text control is set
to the appropriate field name from your table
If that value must be passed to another control on the form, and saved in
the table, then that second field must be bound also.
Say you had a field called FirstName, bound to [FirstName] in your
table... and another field on the form called Other, bound to field [Other]
in your table.
In order to pass that value from FirstName to Other, use the AfterUpdate
event of FirstName with this code...
Me.Other = Me.FirstName

A text control must be bound to a field in your table (ControlSource) in
order to save the value entered into it.
A text control with a (ControlSource) calculation such as =FirstName will
display the FirstName value, but will not store it.

hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions


jimswinder said:
I am trying to create a button that when clicked will take text from a
field
in a form and put it into a field in the table from where the form was
created. Is this possible?
I have tried using the Expression Builder (=[Combo51] = [Combo42] )...but
the text does not get into the table field. Thoughts??
 
F

fredg

Perhaps I should back up a step...
lets say I have 4 fields (all text fields). Field 1 has "I", Field 2 has
"see", Field 3 "red" and Field 4 "spots." What I want to do is combine the
four fields and put the combined text "I see red spots" into a fifh field in
the table. I have no problem combining the fields within a form...but can't
get the new text into the fifth table field.

PS..thanks for fast response!!!! :)

Ronald Roberts said:
jimswinder said:
I am trying to create a button that when clicked will take text from a field
in a form and put it into a field in the table from where the form was
created. Is this possible?
I have tried using the Expression Builder (=[Combo51] = [Combo42] )...but
the text does not get into the table field. Thoughts??

Not sure I understand what you want.
If the form is bound, which means the form has a record source.
And if the controls on the form are bound, which means they have a
control source, then the table will be updated when the user moves to
another record or closes the form.

If you are trying to update a calculated field, don't.
This will lead to other data problems in the future. All calculated
fields or values can be recalculated in a form in an unbound control
or in a query for a report.

Ron

You shouln't save that calculated field.
As Control source of an UNBOUND control on a form or report:

= [Field1] & " " & [Field2] & " " & [Field3] & " " & [Field4]

There is no need to store this result!!!!

As long as you have the other fields data saved, any time you need to
see the combined text, combine them, as above, in a query, form or
report.
 
A

Al Camp

Jim.
I think Fred G understood better than I what you were trying to do.
Did you read his response?
jimswinder said:
Al:

Does the Me in Me.Other = Me.FirstName equal the Table Name?

Al Camp said:
Jim,
If a text control, on a form, is "bound" to a field in your table, any
data entered into that text control will be stored in that field of your
table.
"Bound" means that the ControlSource property of that text control is
set
to the appropriate field name from your table
If that value must be passed to another control on the form, and saved
in
the table, then that second field must be bound also.
Say you had a field called FirstName, bound to [FirstName] in your
table... and another field on the form called Other, bound to field
[Other]
in your table.
In order to pass that value from FirstName to Other, use the
AfterUpdate
event of FirstName with this code...
Me.Other = Me.FirstName

A text control must be bound to a field in your table (ControlSource)
in
order to save the value entered into it.
A text control with a (ControlSource) calculation such as =FirstName
will
display the FirstName value, but will not store it.

hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions


jimswinder said:
I am trying to create a button that when clicked will take text from a
field
in a form and put it into a field in the table from where the form was
created. Is this possible?
I have tried using the Expression Builder (=[Combo51] =
[Combo42] )...but
the text does not get into the table field. Thoughts??
 
A

Al Camp

Fred is demonstrating how to concatenate 4 fields (your example) into one
field... but for display ONLY.
= [Field1] & " " & [Field2] & " " & [Field3] & " " & [Field4]
Since all 4 fields are bound, and saved in the table, there's no need to
save the "I see red spots". You can always reconcatenate them again
later... in any subsequent form or report or query.

In another example, if you saved [Price] and [Qty] you wouldn't have to save
the Cost (=Price*Qty). You would just place an unbound field on your form
with =[Price]*[Qty] and it will always display the correct Cost.
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions


jimswinder said:
Al:

Does the Me in Me.Other = Me.FirstName equal the Table Name?

Al Camp said:
Jim,
If a text control, on a form, is "bound" to a field in your table, any
data entered into that text control will be stored in that field of your
table.
"Bound" means that the ControlSource property of that text control is
set
to the appropriate field name from your table
If that value must be passed to another control on the form, and saved
in
the table, then that second field must be bound also.
Say you had a field called FirstName, bound to [FirstName] in your
table... and another field on the form called Other, bound to field
[Other]
in your table.
In order to pass that value from FirstName to Other, use the
AfterUpdate
event of FirstName with this code...
Me.Other = Me.FirstName

A text control must be bound to a field in your table (ControlSource)
in
order to save the value entered into it.
A text control with a (ControlSource) calculation such as =FirstName
will
display the FirstName value, but will not store it.

hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions


jimswinder said:
I am trying to create a button that when clicked will take text from a
field
in a form and put it into a field in the table from where the form was
created. Is this possible?
I have tried using the Expression Builder (=[Combo51] =
[Combo42] )...but
the text does not get into the table field. Thoughts??
 
J

jimswinder

Here is the ultimate problem (at least for me). I have 34 different tables
all with differing fields that contain descriptions of parts. I need to run a
query that will look at EVERY Field in EVERY Table for a key word. I thought
it would be easier to have the query look in one field rather than up to 340
different fileds. Suggestions?


Al Camp said:
Fred is demonstrating how to concatenate 4 fields (your example) into one
field... but for display ONLY.
= [Field1] & " " & [Field2] & " " & [Field3] & " " & [Field4]
Since all 4 fields are bound, and saved in the table, there's no need to
save the "I see red spots". You can always reconcatenate them again
later... in any subsequent form or report or query.

In another example, if you saved [Price] and [Qty] you wouldn't have to save
the Cost (=Price*Qty). You would just place an unbound field on your form
with =[Price]*[Qty] and it will always display the correct Cost.
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions


jimswinder said:
Al:

Does the Me in Me.Other = Me.FirstName equal the Table Name?

Al Camp said:
Jim,
If a text control, on a form, is "bound" to a field in your table, any
data entered into that text control will be stored in that field of your
table.
"Bound" means that the ControlSource property of that text control is
set
to the appropriate field name from your table
If that value must be passed to another control on the form, and saved
in
the table, then that second field must be bound also.
Say you had a field called FirstName, bound to [FirstName] in your
table... and another field on the form called Other, bound to field
[Other]
in your table.
In order to pass that value from FirstName to Other, use the
AfterUpdate
event of FirstName with this code...
Me.Other = Me.FirstName

A text control must be bound to a field in your table (ControlSource)
in
order to save the value entered into it.
A text control with a (ControlSource) calculation such as =FirstName
will
display the FirstName value, but will not store it.

hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions


I am trying to create a button that when clicked will take text from a
field
in a form and put it into a field in the table from where the form was
created. Is this possible?
I have tried using the Expression Builder (=[Combo51] =
[Combo42] )...but
the text does not get into the table field. Thoughts??
 
J

jimswinder

I know I shouldn't save the result...but is ther any way I can?
Here is the ultimate problem (at least for me). I have 34 different tables
all with differing fields that contain descriptions of parts. I need to run a
query that will look at EVERY Field in EVERY Table for one key word. I
thought
it would be easier to have the query look in one field rather than up to 340
different fileds. Suggestions?



fredg said:
Perhaps I should back up a step...
lets say I have 4 fields (all text fields). Field 1 has "I", Field 2 has
"see", Field 3 "red" and Field 4 "spots." What I want to do is combine the
four fields and put the combined text "I see red spots" into a fifh field in
the table. I have no problem combining the fields within a form...but can't
get the new text into the fifth table field.

PS..thanks for fast response!!!! :)

Ronald Roberts said:
jimswinder wrote:

I am trying to create a button that when clicked will take text from a field
in a form and put it into a field in the table from where the form was
created. Is this possible?
I have tried using the Expression Builder (=[Combo51] = [Combo42] )...but
the text does not get into the table field. Thoughts??


Not sure I understand what you want.
If the form is bound, which means the form has a record source.
And if the controls on the form are bound, which means they have a
control source, then the table will be updated when the user moves to
another record or closes the form.

If you are trying to update a calculated field, don't.
This will lead to other data problems in the future. All calculated
fields or values can be recalculated in a form in an unbound control
or in a query for a report.

Ron

You shouln't save that calculated field.
As Control source of an UNBOUND control on a form or report:

= [Field1] & " " & [Field2] & " " & [Field3] & " " & [Field4]

There is no need to store this result!!!!

As long as you have the other fields data saved, any time you need to
see the combined text, combine them, as above, in a query, form or
report.
 
J

jimswinder

PS...I tried running a query on all of the fields and got an error "Too
Complex..." that's when I went down the path of trying to get the fields into
one field.

fredg said:
Perhaps I should back up a step...
lets say I have 4 fields (all text fields). Field 1 has "I", Field 2 has
"see", Field 3 "red" and Field 4 "spots." What I want to do is combine the
four fields and put the combined text "I see red spots" into a fifh field in
the table. I have no problem combining the fields within a form...but can't
get the new text into the fifth table field.

PS..thanks for fast response!!!! :)

Ronald Roberts said:
jimswinder wrote:

I am trying to create a button that when clicked will take text from a field
in a form and put it into a field in the table from where the form was
created. Is this possible?
I have tried using the Expression Builder (=[Combo51] = [Combo42] )...but
the text does not get into the table field. Thoughts??


Not sure I understand what you want.
If the form is bound, which means the form has a record source.
And if the controls on the form are bound, which means they have a
control source, then the table will be updated when the user moves to
another record or closes the form.

If you are trying to update a calculated field, don't.
This will lead to other data problems in the future. All calculated
fields or values can be recalculated in a form in an unbound control
or in a query for a report.

Ron

You shouln't save that calculated field.
As Control source of an UNBOUND control on a form or report:

= [Field1] & " " & [Field2] & " " & [Field3] & " " & [Field4]

There is no need to store this result!!!!

As long as you have the other fields data saved, any time you need to
see the combined text, combine them, as above, in a query, form or
report.
 
J

jimswinder

Al:
You were close with your "Me.Other = Me.FirstName". I got it to work using
the following in a Command Button:

Private Sub Command54_Click()
Me.PO_Description.Value = Me.Combo42.Value
End Sub

I know most of you said I should not combine fields in a table into another
field in the same table...but I had my reasons. Thanks for all of you that
helped...

Al Camp said:
Jim,
If a text control, on a form, is "bound" to a field in your table, any
data entered into that text control will be stored in that field of your
table.
"Bound" means that the ControlSource property of that text control is set
to the appropriate field name from your table
If that value must be passed to another control on the form, and saved in
the table, then that second field must be bound also.
Say you had a field called FirstName, bound to [FirstName] in your
table... and another field on the form called Other, bound to field [Other]
in your table.
In order to pass that value from FirstName to Other, use the AfterUpdate
event of FirstName with this code...
Me.Other = Me.FirstName

A text control must be bound to a field in your table (ControlSource) in
order to save the value entered into it.
A text control with a (ControlSource) calculation such as =FirstName will
display the FirstName value, but will not store it.

hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions


jimswinder said:
I am trying to create a button that when clicked will take text from a
field
in a form and put it into a field in the table from where the form was
created. Is this possible?
I have tried using the Expression Builder (=[Combo51] = [Combo42] )...but
the text does not get into the table field. Thoughts??
 
Top