Force focus go to subform

G

g

Hello again Friendly Experts,

Hope you can help me out on my problem. I have a main form with a subform
sources are from different tables and master/child link (RecNumber). The main
form(Source MainTable) RecNumber is Autonumber and the subform(SubTable)
RecNumber is number. The problem is that when user enter data and exit
without going to subform it only create records in MainTable. What I need is
that when the user do this I want the RecNumber in SubTable to have a Value
ofcourse similar to the RecNumber on MainTable. I'm thinking is have to set
focus go to subform before exit but the problem is in what field put the
event since most of the fields in mainform are only optional data entry Or
maybe not allow to exit without going to subform first or if you have a
better Idea please let me know.

Thank you in advance for any help
 
A

Allen Browne

There's not a simple answer to this problem. It's a chicken'n'egg situation:
you cannot create the subform record until after the main form record is
saved, and so you cannot require the subform record as a condition for
accepting the main form one. Then, once the main record is created, there's
no guarantee you're going to get a related one.

One possibility is to use the AfterInsert event of the main form to add a
related record. It still doesn't guarantee any sensible data though.

This is generally about trying to help the user not to forget to enter a
related record. (Otherwise you have to also consider what happens if the
user deletes the related records but leaves the main one there.)
 
G

g

Allen,
The least I can do is create an afterinsert event, no worry on deleting
records from the subform or mainform coz user don't have this previlege. What
I did is that afterinsert on two fields on main form the RecNumber on Subform
will get the value at RecNumber from the main form, I did some testing and
work well so far. Even there is no records on subform aside from the
RecNumber my queries will work properly as I used them both table.

Thanks for your advice. I always see your name here in the forum and also
using your website once in awhile and you really have a brilliant mind. Hope
I could learn access more like you.
 

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