Transfter a field value to a field in a different form

G

Guest

Need to know how to transfer a field value to another field in a different
form.

Here is want I have: I have two forms, one called Clients and one called
Events. I have a subform under clients called Events Subform which continues
some information in the form called Events. Then I have a command button
that you click on called "Clients Events" which opens the Events Form which
continues more detail infomation on the clients event. I have another
command button that you can click on called "New Events" which opens the
Event Form with a new record waiting for you to input. When you click on
"New Events" command button you have to manual input the Events Account No.
in that field. I want this field to be inputed automatically from the
Clients Form which the fields is called Clients Account No.

Here is the code I have for the Command Button "New Events":

Dim stDocName As String
Dim stLinkCriteria As String
Dim stAccNo As String

stAccNo = Me.ClientAccountNo
stDocName = "Events"
DoCmd.GoToRecord , , acNewRec
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec

I can't get the command (Me.EventAccountNo = Me.ClientsAccountNo) To work
because it isn't listed with the list box pops up after me. command.

What else can I try? Please help! Also tried setting my default value of
EventAccountNo to stAccNo. Didn't work!
 
G

Guest

Pass the Me.ClientAccountNo using the OpenArgs, in the Open form command line

DoCmd.OpenForm stDocName, , , stLinkCriteria,,,Me.ClientAccountNo

On the OnLoad event of the event form, you can assign the OpenArgs to the
fields

If Not Isnull(Me.OpenArgs) And Me.OpenArgs <> "" Then
Me.EventAccountNo = Me.OpenArgs
End If
 
R

Ron2005

An alternative, but it says that the new events form can only be called
by the previous form,

me.emvenaccountno = forms![clients]!([subform name if there is
one])!ClientAccountNo

Basically, any form can reference controls on any other form that is
open (does not matter if it is hidden or not). you just need to supply
the forms path to get there.
 

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