Copy data from form to form using VB

P

Paul

All I want to do is simply, using VB code that can be
operated from a command button do the following:

I already have a form open which is called "Results Form".

I want to open another form called "Club Members Form"
and copy a data from "Results Form" to the "Club Members
Form".

So far I have:

Dim stDocName1 As String
Dim stDocName2 As String

stDocName1 = "Club Members Form"
stDocName2 = "Results Form"

DoCmd.OpenForm stDocName1
DoCmd.OpenForm stDocName2

stDocName1![Value] = stDocName2![Value]

By the way there are fields on each form called "Value"

So all I want to do is copy a value from the "Value"
field on the "Results Form" and paste it into the
field "Value" on the "Club Members Form".

Any help on this would be greatly appreciated
 
D

Dirk Goldgar

Paul said:
All I want to do is simply, using VB code that can be
operated from a command button do the following:

I already have a form open which is called "Results Form".

I want to open another form called "Club Members Form"
and copy a data from "Results Form" to the "Club Members
Form".

So far I have:

Dim stDocName1 As String
Dim stDocName2 As String

stDocName1 = "Club Members Form"
stDocName2 = "Results Form"

DoCmd.OpenForm stDocName1
DoCmd.OpenForm stDocName2

stDocName1![Value] = stDocName2![Value]

By the way there are fields on each form called "Value"

So all I want to do is copy a value from the "Value"
field on the "Results Form" and paste it into the
field "Value" on the "Club Members Form".

Any help on this would be greatly appreciated

Answered in a different newsgroup to which you posted this question
independently. That's called "multiposting", and it's generally frowned
on because others don't know what answers have already been given, and
so they duplicate the effort. Also it's harder for you to keep track of
the various replies, and it's harder for later readers of the question,
who may be looking for the same answer, to learn what they need.

In most cases a single, well-chosen newsgroup will do. If your question
really is relevant to more than one newsgroup, the approved technique is
to "crosspost" it instead, by listing multiple newsgroups in the To: or
Newsgroups: line of a single message. If you do that, the message and
any replies will appear in all the listed newsgroups automatically,
which is beneficial to all concerned.
 
W

will eichert

This should work. I usually use the Forms keyword to identify the
form, and I don't know if it's optional or not.

Forms![Club Members Form]!Value

Maybe naming a control Value is confusing it?

Or maybe it's working and you're just not seeing it because you didn't
do a refresh after setting your control.

Forms![Club Members].Refresh, if I remember correctly

Will
 

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