Auto enter an ID # in a sub-form

P

Paul

I have a form with a button that opens a sub-form when I click on the button.
The "ID#" fields are linked via relationship between the form and sub-form.
When the sub-form opens, the ID # on the sub-form defaults to O. In order to
tie the sub-form to the form, you must enter the ID # from the form to the
sub-form. If the user forgets to enter the number, or enters the wrong
number, then the entry is tied to the wrong entry of the form.
Can anyone tell me how to auto enter the number from the ID# field on the
form into the ID# field on the sub-form?
Thanks, Paul
 
J

Jeff Boyce

Paul

In a standard mainform/subform construction, the subform control (on the
main form) has two properties. One points to the field/control on the main
form that has the ID. The other points to the field/control on the subform
that shares that ID.

Neither you nor your users EVER need to (re-)enter the ID on the subform --
if you use these properties, Access will insert the ID into a (new) subform
record when you first 'dirty' it.

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or psuedocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
J

John Vinson

Paul said:
I have a form with a button that opens a sub-form when I click on the button.
The "ID#" fields are linked via relationship between the form and sub-form.
When the sub-form opens, the ID # on the sub-form defaults to O. In order to
tie the sub-form to the form, you must enter the ID # from the form to the
sub-form. If the user forgets to enter the number, or enters the wrong
number, then the entry is tied to the wrong entry of the form.
Can anyone tell me how to auto enter the number from the ID# field on the
form into the ID# field on the sub-form?
Thanks, Paul

It sounds to me like this isn't actually a Subform (which is always open in
a Subform window on the mainform, and which has a master/child link field
property to do this for you); it sounds like you're instead popping up a
separate form. Is that intentional, or would a Subform be acceptable (since
it takes care of this issue for you with no code or effort at all)?
 
K

KARL DEWEY

You would not have this problem if the table for the form had a primary key
field and you set a one-to-many relationship the the table for the subform.
In tthat relation select the Referential Integerity and Cascade Update
options.
When a record is added in the subform the ID will automatically be added so
there is no need to display it in the subform.
 
R

rruston

I had this problem, too. How I solved it is that I set the Default property
for the control for the ID# of the subform to equal the ID# of the main form.
I used the Expression Builder. Good Luck!
 
Y

yamakamiã„ã‚‹ã‹

ç§ã¯ã€ã©ã†ã—ã¦ã€ã“ã‚“ãªã«ã€è¾›ã„日々をã€ï¼Ÿï¼Ÿï¼Ÿ

トラジ(河æ‘ã¤ã‚ˆã—)ã¯ã€ç§ã«ã€ãƒ¬ã‚¤ãƒ—ã—ãŸäººï¼ï¼ï¼ï¼ï¼

æºå¸¯ï¼ï¼™ï¼ï¼ï¼˜ï¼–ï¼ï¼—ï¼ï¼˜ï¼–11


ワンギリスタートï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼



watasiha,

zettaini,yurusanai!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


borantyia,

okaneha,

sonnnani,irimasen,

hisasiburini,

ge-senni,ikereru,kuraiha,

hosiidesuga???!!!!


ãれ以外ã¯ã€ã„ã‚Šã¾ã›ã‚“ï¼ï¼â™ª

ãã‚“ãªã€é«˜é¡ã‚’もらã„ãŸãã¯ã€ãªã„ã§ã™ï¼ï¼â˜†

ãã‚“ãªã€ãŠé‡‘ãŒã€ã‚ã£ãŸã‚‰ã€ç›²å°ŽçŠ¬ã«ã€å¯„付ã—ãŸã„ã¨ã€æ€ã£ã¦ã„ã¾ã™ï¼ï¼ï¼

ユニセフã¨ã‹ã¯ã€ä¸Šã®äººã°ã‹ã‚ŠãŒã€å–ã£ã¦ã€æœ¬å½“ã«ã€å¿…è¦ãªã€è²§ã—ã„人ãŸã¡ã«ã¯ã€å…¨ããŠé‡‘ãŒã€ã„ã£ã¦ã„ãªã„ã¨ã„ã†ã“ã¨ã‚’ã€çŸ¥ã‚Šåˆã„ã‹ã‚‰ã€èžãã¾ã—ãŸï¼ï¼ï¼

honntouno,koto,rasii,desuyo!!!!!!!!!!!!!

watasiha,

usoo,tukuhitoga,

daikirai!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 

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