Open form in add mode with name field populated

  • Thread starter Thread starter Sammy
  • Start date Start date
S

Sammy

What's the code to launch a form in add mode from another
form using a command button, and populate the new record
with data from the first form?
Form 1 field: LavaClient
Form 2 field: Client. Form should open in add-record
mode.
Form 1 command button needs to take the value of
LavaClient and put it in the Client field of form 2.
Thanks!
 
Sammy,

Try this:

DoCmd.OpenForm "Form2", acNormal, , , acFormAdd , , Me.LavaClient
Form2.Client = OpenArgs

in the command button click event. Just change Form2 to the actual name of
the second form in both lines.

HTH,
Nikos
 
Thanks. This opens form 2, but does not populate the
data from form 1 into form 2. I get an error: "object
required".

Here's my code:
DoCmd.OpenForm "LavaReceipts", acNormal, , , acFormAdd, ,
Me.LavaSoldTo
LavaReceipts.LavaClient = OpenArgs

When I debug it, I see the value of OpenArgs is null, but
the value of Me.LavaSoldTo is correct.


Thanks.
Sammy
 
Sammy,

I suspect this is a classic case of word wrapping working its miracle in the
newsgroups postings... Me.LavaSoldTo is at the end of the DoCmd line, not on
the next one. This is where OpenArgs is assigned the Me.LavaSoldTo value.

HTH,
Nikos
 
Nikos,
It is word wrapping, but it's word wrapping in the
newsgroups, not in my code. The Me.LavaSoldTo is at the
end of the DoCmd line in my code. I'm still getting the
error. Can we try something else?
Thanks.
Sammy
 
if you want to open the form with the client field populated when a button is pressed

in the on click properties of the button typ

dim frm as for

docmd.openform "form2" - set the openargs to dataentry at this poin

set frm = forms!form
frm.controls!client = me!lavaclien
 
Back
Top