Getting information from one form to another

G

Guest

Hi,

I am fairly new to Access.

I have designed a primary form (form 1)for data entry with a primary key. I
have a series of buttons on the form that open other forms (form 2, 3, 4
etc.) which will store data related to information on form 1.

When opening form 2, for example, I would like the primary key number from
form 1 to be visible in a text box on form 2, but am not sure how to go about
it.

Any suggestions would be appreciated.

James
 
J

JP

There are two approaches you can use

1. If the primary key from form1 is going to be the primary key or part of
the primary key for the records in forms 2, 3, 4, etc., then you might want
to make forms 2, 3, 4 etc into subforms of form1 and pass the primary key as
the link field. That's the whole purpose of linked subforms.

or

2. In a code module, create a global variable (e.g., gPrimary_Key). When
the user presses any of the open form buttons on Form 1, store the value of
the Primary Key into variable gPrimary_Key. Then in the OnCurrent event of
other Forms (2, 3, 4, etc.), store the value of gPrimary_Key into the
appropriate textbox.

You should consider getting yourself a good book on Access
Development/Programming. There are various books from Sybex, Wrox,
Microsoft Press, Sams, Que, etc.
 
G

Guest

Hi JP,

Thanks. I took the global variable option and it works very well. I knew
that I could accomplish this using subforms, but my present from is already
quite cluttered and didn't feel I could put anything more on it.

I have two rather thick Access books that I have been looking through, but I
just couldn't seem to find what I was needed.

Thanks for your help.

James
 

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