Open Form button

L

LAP

I'm using Access 97 and I created a button using the
wizard that opens a form and finds specific data to
display. It works fine and displays appropriately
matched records. However, when I want to create a new
record in Form A and then click the button to create a
new correcsponding record in Form B, I would like
the "key" field to auto populate based on the previous
record I just entered. Right now, it simply gives me a
new record row for data entry. I'm sure I need to pass a
variable from one to the other but I'm not sure how to do
that.

Thanks for your help
LeAnn
 
N

Nikos Yannacopoulos

LeAnn,

An easy way to do this is to use the OpenArgs argument of the OpenForm
method; assuming the name of the control on the first form whose value you
want to pass to the second form is TextA, and the name of the target control
on the second form is TextB, then:

The code behind the command button on the first form should be something
like:

DoCmd.OpenForm "SecondFormName", , , , , , Me.TextA

Then, in the On Open event of the second form, you should have a code line
like:

Me.TextB = Me.OpenArgs

HTH,
Nikos
 
L

LAP

Thanks Nikos. I thought it would have something to do
with OpenArgs but I couldn't find any good reference
material explaining how to use this. I have 2 decent
Access reference guides and read online help but they
didn't help me. Do you have a recommended source that
might explain this a little more?

Thanks
LeAnn

P.S. I got it to work a different way by using the
ISLOADED (Form OnLoad) and setting the value of my
textbox equal to the value from my first form.
 
N

Nikos Yannacopoulos

LeAnn,

Glad you got it working, this method is just as good I guess. I'm afraid I
am not in position to recommend a reading source, I'm one of those
mazochists who try to figure it out on their own, relying on instinct,
application help and the internet (I didn't have the latter when I first
started with Access some nine years ago!).

Nikos
 

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