How do I automatically fill in values from another form?

G

Geogeek

Hey there,

Could really use some help on how to automatically fill in a control with a
value from a preceeding form. I'm using several forms to enter various
properties/data for water wells. I just want to be able to enter the "well
name" in the first form, then use a button (e.g. "Next") to close the form
and open the next corresponding form with the well name automatically
displayed. I only need the "well name" to be saved in the first table.

So far, I can perform this task using a macro in "AfterUpdate" of the first
form. However, when I close the form using the "Next" button, I just get an
error message.

If my problem makes any sense, could someone please give some clues for what
to try?

Many (advanced) thanks!
 
H

hfnet

You could use the OpenArgs to pass the value to the new form, or you could
use the button to set the current form as visible = False, open the new form
and popluate any required fields on the new form using the
Me.txtExample1.Value = Forms!<non-visibleformname>!txtFieldtocopy.Value idea,
then close the old form once used.
 
G

Geogeek

hfnet,

Thank you for your response. Unfortunately, I wasn't able to figure out how
to use your methods. They appear to be an approach using VisualBasic, which
I haven't a clue how to use properly. However, the fact that I got a
response to my problem inspired me to keep trying (since there was obviously
some way to make it work).

This probably isn't the most efficient way of doing this, but I finally got
it to work by doing the following:

First, I added a text box to the second form (leaving the default name as
"Text2" for the text box). Then I created a macro using "SetValue" with the
"Item" defined as: [Forms]![A2_Location]![Text2], and the "Expression"
defined as: [Well_Name].

Next, I set the "AfterUpdate" in the primary form to the macro. Also, the
"Next" button in this form remained the same, which uses a macro to open the
second form and close the active form.

Now, when I close the primary form, the second form (i.e. A2_Location) opens
with the well name displayed at the top of the form. I used the same concept
for the remaining 7 forms.

Thanks again for your response. Geogeek
 
Top