A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

prefill a field into another form



 
 
Thread Tools Display Modes
  #1  
Old December 17th, 2006, 05:30 PM posted to microsoft.public.access.forms
accessuser via AccessMonster.com
external usenet poster
 
Posts: 66
Default prefill a field into another form

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!!!

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200612/1

  #2  
Old December 17th, 2006, 06:39 PM posted to microsoft.public.access.forms
[email protected]
external usenet poster
 
Posts: 20
Default prefill a field into another form


accessuser via AccessMonster.com wrote:
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.



Thanks!!!

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200612/1


  #3  
Old December 17th, 2006, 08:13 PM posted to microsoft.public.access.forms
accessuser via AccessMonster.com
external usenet poster
 
Posts: 66
Default prefill a field into another form

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!

wrote:
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!!!

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200612/1

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200612/1

  #4  
Old December 17th, 2006, 09:35 PM posted to microsoft.public.access.forms
accessuser via AccessMonster.com
external usenet poster
 
Posts: 66
Default prefill a field into another form

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!

accessuser wrote:
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]
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200612/1


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200612/1

  #5  
Old December 17th, 2006, 10:39 PM posted to microsoft.public.access.forms
Cheese_whiz
external usenet poster
 
Posts: 391
Default prefill a field into another form

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

"accessuser via AccessMonster.com" wrote:

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!!!

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200612/1


  #6  
Old December 17th, 2006, 11:31 PM posted to microsoft.public.access.forms
accessuser via AccessMonster.com
external usenet poster
 
Posts: 66
Default prefill a field into another form

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 wrote:
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!!!


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200612/1

  #7  
Old December 18th, 2006, 01:43 PM posted to microsoft.public.access.forms
Cheese_whiz
external usenet poster
 
Posts: 391
Default prefill a field into another form

Try leaving out the "Form!"

So:

=Forms!Mainform!controlOnMainform!CourseID

The above works for me, anyway, in a quick db I setup to test it.

Good Luck,
CW

"accessuser via AccessMonster.com" wrote:

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 wrote:
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!!!


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200612/1


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:55 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.