Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tab from subform to main form after record added on main form 1

Status
Not open for further replies.

punky

Programmer
Mar 21, 2001
29
US
Tab from subform to main form after record added on main form gives this error message "You Must Be On A Record
With Data". I click on OK. After I manually go back to the main form and then to subform again, this message does not appear when I tab from the subform to the main form.

It's as if the new record added on the mainform is not
recognized on the subform when I am trying to tab from subform to mainform, regardless of whether I key
info into the subform or not.

If a subform record exists, with data in it, I DO NOT get
this message. Only when adding a new record on the mainform
and tabing to the subform and then trying to tab back to the
mainform, do I get this message.

How can I make the subform add this record and recognize
the record regardless of whether I key info in or not.

The child/master link is ok.
 
Possibly the main record does not actually exist at that point cos Access has not written it. If you set record selectors on on the main form, then you should not have a pencil mark in same when you go to the subform. You may need to save the record yourself to create the link (paste the code from the save record wizardy button).

I had something similar this evening albeit with a different (i.e. none ) error message.
 
What you might try doing is having the main form refresh (
Code:
me.requery
or
Code:
me.refresh
) after you add a new record on the main form.

then... to switch to the subform, after the refresh, simply set focus to the subform. (
Code:
sbfMySubform.setfocus
) If your subform is linked to the mainform properly, and the subform allows additiions/edits, the
Code:
setfocus
command should put it to the first field in the subform in the tab order. Earnie Eng
Newbie Access Programmer/DBA
(I just got a job! yay!)
Code:
---------------------------------
If you are born once, you will die twice.
If you are born twice, [i
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top