Question Refresh,update but keep focus

ENEMAL

Registered User.
Local time
Today, 12:31
Joined
Nov 18, 2012
Messages
11
I have exausted my novice knowledge over this.
I have three tables namely StudentRecord, session and payments
StudentRecord has these fields
StudentID (pri. Key)
Name
Address .....

Session has these fields
SessionID (pri. Key)
StudentID ( f. Key)
Schoolyear

Payments has these fields
PaymentID ( pri. Key)
SessionID ( f.key)
AmountPaid


Now I created a main form called studentRecord using the studentRecord table as record source.
Then I created two subforms called session subform and payments subform all attached to the main form(studentRecord)
I want a VBA if I enter a record in session subform,the payments subform automatically register the sessionID of that record and setfocus on the sessionID of that record.
Because at the moment I have to close and reopen the form or manually refresh all or move to previous record and back before a new record from session subform is registered in payments subform

Any help is welcomed (access 2007)
 
You don't need any VBA Code to transfer the SessionID value to the Payments record.

First, open the attached images (both Form View and Design images) and take a look at them.

1. You must link the Student Main Form to the Session Form with StudentID.
2. Payment Form must be linked to the SessionID field of Session Form. It cannot be done directly as you do for Student main form and Session Form, but through a Unbound Textbox created on the Main Form.

Let us link the Forms (Student Main Form to Session Form and Session Form to Payments Form) properly.
  1. Click on the border of the Session Form to select it, don't click inside the Session Fom.
  2. Press F4 to display the Property Sheet.
  3. Click on the Data Tab of the Property Sheet.
  4. Type StudentID in the Link Master Fields and Link Child Fields Properties.
  5. Create an Unbound Textbox somewhere on the Student Main form.
  6. Change its Name Property Value to Session_ID.
  7. Type the expression: =[Session].Form![SessionID] in the Control Source Property.
  8. You may set the Visible property value to No to keep this text box in hidden state.
  9. Click on the border of Payments Form to select it.
  10. Type Session_ID in the Link Master Fields property.
  11. Type SessionID in the Link Child Fields property.
  12. Save the Forms and open the Student Main Form in normal view.

When you select a particular Student record on the Main Form it's corresponding Session Record(s) will appear in the Session Form. When you select a particular session record on the Sessions Form it's corresponding Payment record, if exists, will show up on the Payment Form. If you enter a new Session record with a new SessionID you will see a record with the same SessionID appearing on Payment Form ready to enter other details of payment record.
 

Attachments

  • StudentForm.jpg
    StudentForm.jpg
    56.9 KB · Views: 129
  • StudentForm_Design.jpg
    StudentForm_Design.jpg
    93.8 KB · Views: 112
Uncountable thanks to you apr and Sorry for the late reply. I was on a very long journey. But after following all your steps, everything worked perfectly just as I wanted.
I used SessionID instead of Session_ID ( without underscore ) because my table has no underscore . Thanks again
 

Users who are viewing this thread

Back
Top Bottom