Add data from one field to another

D

Dimitris

Hello,
What I need is in each record of a form to be able to add the data of one
field to another field. For example: There is the field F1 and the user
entered the word "Europe" in that field. When he comes to the field F2 I
would like the user to be able by clicking on a button or something to add
the word "Europe" of F1 to F2. That must not be always done but only if the
user wishes to?
Is it possible?
Thanks you
Dimitris
 
K

Keith W

Dimitris said:
Hello,
What I need is in each record of a form to be able to add the data of one
field to another field. For example: There is the field F1 and the user
entered the word "Europe" in that field. When he comes to the field F2 I
would like the user to be able by clicking on a button or something to add
the word "Europe" of F1 to F2. That must not be always done but only if
the user wishes to?
Is it possible?

Yes it is but why you'd want to do it is another issue. In a command button
On Click even you'd need something like:

Me.Refresh
Me.txtF2 = Me.txtF1

Where txtFn are the names of your text boxes.

HTH - Keith.
www.keithwilby.com
 
R

Rick B

That would be redundant. Proper database design would indicate that you
should not do this.
 
D

Dimitris

Thanks Keith.
I did what you said but it did not work.
After clicking on the button I get the error message:

Compile error:
Method or data member not found

The code is:

Private Sub combut_Click()
Me.Refresh
Me.txtEPONYMO = Me.txtONOMA

End Sub

where:
combut is the name of the command button
EPONYMO the first field
and ONOMA the name of the second field

Also the part .txtONOMA of the code is selected when I get the error
message and Private Sub combut_Click() is yellow.
I also switched the names of the fields in the code, but still no luck.
Any idea?
Dimitris
 
G

Guest

Dimitris,

I agree with Rick B., in that this is likely totally unnecessary and
redundant, but please post the nature of these two fields, and we'll be
better able to advise.

In regard to the given code, the names on either side of the = sign should
be the names of the form *controls* that are bound to their corresponding
fields, respectively. Perhaps you never named them with the "txt" prefix?
Also, the Bang operator (!) is preferred to a period (.) to delimit an object
from its collection. Periods are intended to separate an object from its
methods and properties. The period works in this case, but makes the code
less readable and clear.

Private Sub combut_Click()
Me.Refresh
Me![NameofYourEPONYMOControl] = Me![NameofYourONOMAControl]
End Sub

Sprinks
 
D

Dimitris

I have one last question.
After clicking the button the user can't go leave the button and going on to
the next field by pressing ENTER. Only with the arrows.
Can it be fixed so you can go on with Enter?
Thanks again.
 
G

Guest

Set the focus to the next control explicitly:

Me![YourNextControl].SetFocus

Sprinks
 
D

Dimitris

Thank You Sprinks.
I finally got what I needed.

Sprinks said:
Set the focus to the next control explicitly:

Me![YourNextControl].SetFocus

Sprinks

Dimitris said:
I have one last question.
After clicking the button the user can't go leave the button and going on
to
the next field by pressing ENTER. Only with the arrows.
Can it be fixed so you can go on with Enter?
Thanks again.
 

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