RE: 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/Forums.aspx/access-forms/200612/1


.