Form Output Into New Record In A Different Form?

P

PowerLifter1450

Hi all, I have a form that shows student information (primary key =
student ID). I have buttons on this form to bring up other forms that
can be used to register student for certain events. The first form is
data from a student table, while the ones for registering the student
are connected to a table s called Students Registered for an event
(primary key = Student ID + Event ID).

The problem is, then when you open the registration form, you have to
manually put in the Student ID as input. I would like to pull whatever
Student ID was currently showing in the Student form to be
automatically put into the registration form.

Any help is much appreciated. Thanks,

--Eric
 
G

Guest

I will make the assumption that on the STUDEN form you have a button that
causes the registration form to be opened.
Let's call the button btn_OpenRegistrationForm.
Lets call the registration form frm_StudentRegistration

In the btn_OpenRegistrationForm OnClick event

' Pass the current Student ID to the other form via the "OpenArgs" parameter
DoCmd.OpenForm "frm_StudentRegistration",acNormal, ,,,,Me.[Student ID]



In form frm_StudentRegistration, up at the top, just below the Option
Explicit and before any code, define a variable of the appropriate data type
(probably a LONG if Student_ID is an AutoNumber in the table)

DIM long_StudentID As Long

In the form's FORM_OPEN() event

long_StudentID = Me.OpenArgs

IN the form's BeforeInsert event

Me.[Student_ID] = long_StudentID

Here I assume that you have a bound control on the form named Student_ID.
It need not be visible.
 
P

PowerLifter1450

I will make the assumption that on the STUDEN form you have a button that
causes the registration form to be opened.
Let's call the button btn_OpenRegistrationForm.
Lets call the registration form frm_StudentRegistration

In the btn_OpenRegistrationForm OnClick event

' Pass the current Student ID to the other form via the "OpenArgs" parameter
DoCmd.OpenForm "frm_StudentRegistration",acNormal, ,,,,Me.[Student ID]

In form frm_StudentRegistration, up at the top, just below the Option
Explicit and before any code, define a variable of the appropriate data type
(probably a LONG if Student_ID is an AutoNumber in the table)

DIM long_StudentID As Long

In the form's FORM_OPEN() event

long_StudentID = Me.OpenArgs

IN the form's BeforeInsert event

Me.[Student_ID] = long_StudentID

Here I assume that you have a bound control on the form named Student_ID.
It need not be visible.



Hi all, I have a form that shows student information (primary key =
student ID). I have buttons on this form to bring up other forms that
can be used to register student for certain events. The first form is
data from a student table, while the ones for registering the student
are connected to a table s called Students Registered for an event
(primary key = Student ID + Event ID).
The problem is, then when you open the registration form, you have to
manually put in the Student ID as input. I would like to pull whatever
Student ID was currently showing in the Student form to be
automatically put into the registration form.
Any help is much appreciated. Thanks,
--Eric- Hide quoted text -

- Show quoted text -

That worked awesome; thanks a lot for your help!!

--Eric
 

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