prefill a field into another form

  • Thread starter accessuser via AccessMonster.com
  • Start date
A

accessuser via AccessMonster.com

I have a subform with courseinfo, and a CmdAddCost "AddCost' and it opens up
a Data Entry form where users can input their new info. on the Subform there
is a CourseID (PK), and the FrmCostAdd also have CourseID as Foreign Key. I
want to know if there a way that I can let the system know to prefil the
CourseID number when I open up the FrmCostAdd. Current'y i have it to
manually input the CourseID, otherwise they won't link. What I am concerned
is they might put in the wrong ID and it will be mislinked.

As for the FrmCostAdd CourseID is a foreign key, should i set the index as
"Yes Duplicate Ok" or "Yes Duplicate No", I have the "Yes Duplicate Ok" now,
but not sure if it wil affect my data later on. can someone help me to
answer these two questions.


Thanks!!!
 
H

Hung.cao

accessuser said:
I have a subform with courseinfo, and a CmdAddCost "AddCost' and it opens up
a Data Entry form where users can input their new info. on the Subform there
is a CourseID (PK), and the FrmCostAdd also have CourseID as Foreign Key. I
want to know if there a way that I can let the system know to prefil the
CourseID number when I open up the FrmCostAdd. Current'y i have it to
manually input the CourseID, otherwise they won't link. What I am concerned
is they might put in the wrong ID and it will be mislinked.

in the frmcostadd in the open .... you may want to have assign the
field = to the field where you get the data from.
As for the FrmCostAdd CourseID is a foreign key, should i set the index as
"Yes Duplicate Ok" or "Yes Duplicate No", I have the "Yes Duplicate Ok" now,
but not sure if it wil affect my data later on. can someone help me to
answer these two questions.

It will not affect your data. If you have "Yes Duplicate Ok" it will
let you save the record and move on. Otherwise, you will not able to
save the record. I would keep "Yes Duplicate Ok" but before the save
the record i would do a quick find if the key is exist and popup the
error if it's.

Hope i'm making some sense and best to you.
 
A

accessuser via AccessMonster.com

I tried the Control Source of the FrmCostAdd =[Forms]![fsubCourseInfo]!
[CourseID], but it is not working, it is giving me the "#Name".....Do you
possibly have any codes for this. I never worked on a link form before,
still learning all those errors from acess.

Thanks!

I have a subform with courseinfo, and a CmdAddCost "AddCost' and it opens up
a Data Entry form where users can input their new info. on the Subform there
[quoted text clipped - 3 lines]
manually input the CourseID, otherwise they won't link. What I am concerned
is they might put in the wrong ID and it will be mislinked.

in the frmcostadd in the open .... you may want to have assign the
field = to the field where you get the data from.
As for the FrmCostAdd CourseID is a foreign key, should i set the index as
"Yes Duplicate Ok" or "Yes Duplicate No", I have the "Yes Duplicate Ok" now,
but not sure if it wil affect my data later on. can someone help me to
answer these two questions.

It will not affect your data. If you have "Yes Duplicate Ok" it will
let you save the record and move on. Otherwise, you will not able to
save the record. I would keep "Yes Duplicate Ok" but before the save
the record i would do a quick find if the key is exist and popup the
error if it's.

Hope i'm making some sense and best to you.
Thanks!!!
 
A

accessuser via AccessMonster.com

I think i want to go with the adding a message alerting the users that The
ID has already created....how would i do that? Have the system run the query
check to double check there is no duplicate??

thanks!
I tried the Control Source of the FrmCostAdd =[Forms]![fsubCourseInfo]!
[CourseID], but it is not working, it is giving me the "#Name".....Do you
possibly have any codes for this. I never worked on a link form before,
still learning all those errors from acess.

Thanks!
I have a subform with courseinfo, and a CmdAddCost "AddCost' and it opens up
a Data Entry form where users can input their new info. on the Subform there [quoted text clipped - 23 lines]
 
C

Cheese_whiz

There's probably several ways to do it. One would be to use vba attached to
the onclick event of the command button, the other would be to put an
expression in the default value of the form that opens up.

The problem is I'm almost surely going to get the syntax wrong, and though I
could get it right if it were in front of me, it's not in front of me.

I think, for the default value of the courseID on the form that opens,
assumming you are getting the value from a control on a subform that is in a
form that's opened already, would be:

=Forms!Mainform!controlOnMainform!Form!CourseID

To explain a little further, the "Forms" is typed just like above: Forms.
The "Form" is also typed like it is above: Form. The "Mainform" is the name
of your main form, the "controlonmainform" is the name of the control that
holds the subform (not necessarily the subform name, but it often is).

I think that's the right syntax, but know going in if that doesn't work,
it's because hte syntax is wrong, not the technique.

NOTE: This works ONLY if the main form that holds the subform is OPEN when
you open the second form (the one you want to open with the mathcing values).

Note 2: That code goes into the "default value" of the control on the second
form. To put it there, open the second form in design mode, click on the
text box where you want the value to appear, hit f4 to open the properties
window if it's not already open, click on the data tab, and type that code
into the space beside where it says "default value".

I hope this helps (and is the proper syntax).

CW
 
A

accessuser via AccessMonster.com

Thanks for the reply.,....., i tried the code and didn't work. so i guess i
will just stay with the manually input for the courseid. Thank you!


Cheese_whiz said:
There's probably several ways to do it. One would be to use vba attached to
the onclick event of the command button, the other would be to put an
expression in the default value of the form that opens up.

The problem is I'm almost surely going to get the syntax wrong, and though I
could get it right if it were in front of me, it's not in front of me.

I think, for the default value of the courseID on the form that opens,
assumming you are getting the value from a control on a subform that is in a
form that's opened already, would be:

=Forms!Mainform!controlOnMainform!Form!CourseID

To explain a little further, the "Forms" is typed just like above: Forms.
The "Form" is also typed like it is above: Form. The "Mainform" is the name
of your main form, the "controlonmainform" is the name of the control that
holds the subform (not necessarily the subform name, but it often is).

I think that's the right syntax, but know going in if that doesn't work,
it's because hte syntax is wrong, not the technique.

NOTE: This works ONLY if the main form that holds the subform is OPEN when
you open the second form (the one you want to open with the mathcing values).

Note 2: That code goes into the "default value" of the control on the second
form. To put it there, open the second form in design mode, click on the
text box where you want the value to appear, hit f4 to open the properties
window if it's not already open, click on the data tab, and type that code
into the space beside where it says "default value".

I hope this helps (and is the proper syntax).

CW
I have a subform with courseinfo, and a CmdAddCost "AddCost' and it opens up
a Data Entry form where users can input their new info. on the Subform there
[quoted text clipped - 10 lines]
Thanks!!!
 

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