Transfering a field value in a form to another

G

Guest

I have a form called Clients and another form called Events. Both have a
same field but is called different names the field in Clients is called
ClientsAccountNo and the one in Events is called EventsAccountNo. I have
setup a command button on the clients form to create a new event for that
client. That part works great but I have to input the EventAccountNo into
it's field. I want this field to be inputed automatically from the
clientsaccountno, it is the same value which I use to link the two table
together in a subform. How do I do this?
 
S

Steve Schapel

Rickster,

Do you mean you have a Clients form, and an Events form, with the Events
form placed into the Clients form as a subform? In that case, if you
set the Link Master Fields property of the subform to ClientsAccountNo,
and the Link Child Fields property of the subform to EventsAccountNo,
than the EventsAccountNo value should be automatically entered into
every new record created in the Events subform, there is no need for you
to do anything.

Please let me know what I am missing if I have misinterpreted you here.
 
J

John Vinson

I have a form called Clients and another form called Events. Both have a
same field but is called different names the field in Clients is called
ClientsAccountNo and the one in Events is called EventsAccountNo. I have
setup a command button on the clients form to create a new event for that
client. That part works great but I have to input the EventAccountNo into
it's field. I want this field to be inputed automatically from the
clientsaccountno, it is the same value which I use to link the two table
together in a subform. How do I do this?

If it's really a Subform, no command button is necessary: simply make
ClientsAccountNo the Master Link Field and EventsAccountNo the Child
Link Field. When you create a new record in the subform (just by
typing into it!) it will automatically inherit the value from the
mainform.

If you're actually running code to pop up a separate form, you'll need
to write VBA code to pass the ClientsAccountNo as the OpenArgs
argument of the OpenForm method, and in the Events form's Open event,
set the DefaultValue property of the EventAccountNo control to the
value from OpenArgs.


John W. Vinson[MVP]
 
G

Guest

I have a master client form which has all our client information in it like
contact information then I have a subform listing only some of the fields in
the event table. When you click on a command button called "Clients Events",
you see a more detailed form for all the events for that client. I also
have a command button called "Add New Event" Which adds a new event to the
selected client. When this form pop-ups you have to enter the field called
"EventsAccountNo" which has a relationship to a field called
"ClientsAccountNo" These two fields I use to link the subform to the clients
form. The problem I'm having is when you click on "Add New Event" which I
used the Open Form in the Form Wizard. You have to manually input
"EventsAccountNo" into it's field. So you have to remember it from the
clients form and enter it into the events form. I want "EventsAccountNo" to
have the some value has "ClientsAccountNo" so you don't have to input this
Account Number. I don't know if this makes any sense to anybody but thanks
anyway.

Rickster172
 
S

Steve Schapel

Rickster,

Ok, I think I understand what you are doing. I think you could put code
like this on the Click event of the Add New Event command button...

DoCmd.OpenForm "WhateverYourFormIsCalled"
Forms!WhateverYourFormIsCalled!EventsAccountNo = Me.ClientsAccountNo

In the code that you use to close this form, it would be a good idea to
include to Requery the events subform on the master client form.
 

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