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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subform Control Values

Status
Not open for further replies.

tlove161

Technical User
Feb 5, 2004
42
0
0
US
I have a main form named "fromRovingPatrol_01" and a subform on that form named "fsubArrests". There is a textbox on the subform named "Text27" which contains a dlookup function to get a code number. I need to assign the value of "Text27" to the "Code" textbox on the same subform.

I need this code to run during an AfterUpdate event on the subform. I have tried this piece of code to no avail;

Forms![frmRovingPatrol_01]![fsubArrests].Form!
Code:
 = Forms![frmRovingPatrol_01]![fsubArrests].Form![Text27]

I have also tried several variations that do not work.  What am I doing wrong?  Thank you in advance.  Troy
 
Hi tlove

I may be wrong , but if the combobox on the subform is the thing which is being updated then isn;t the subform which has the focus and therefore the code should be something like

me.
Code:
 = me.[text27]

in the afterupdate of the [COLOR=red]TEXT27[/color] textbox

Ian Mayor (UK)
[COLOR=blue]Program Error[/color]
Programmers do it one finger at a time!
 
ProgramError-

Unfortunately your suggestion did not work. I did not get any errors, but the code from "Tex27" was not assigned to the "Code" field of the underlying table linked to the subform.

Any other suggestions? Thank you. Troy
 
Couple of things
* I don't think the after update event of form controls fire unless the user stuffs any data into it manually - so the result of a domain aggregate, would probably not fire it
* I think the After Update event of the form (hence the name), fires after it's updated the data to the table (after the save) - utilizing it to stuff data into other controls, will probably create amusement - either an endless loop (saving, after which the after update fires, saving, fire the after update, saving...) or some error

- I would try using the before update event of the form in stead - and since this is running on the subform, just use the Me!
Code:
.value syntax, no need to reference through the main form

Roy-Vidar
 
Roy-Vidar
I moved "Me.Code = Me.Text27" into the AfterUpdate event of the form and I am still getting the same error. "The value you entered isn't valid for this field." Any other suggestions? Thanks.
 
RoyVidar suggests to move it to the BEFORE Update event


Pampers.

You're never too young to learn
 
pampers-

I moved "Me!
Code:
.Value = Me![Text27].Value" to the BeforeUpdate event of the form and it still does not work.  The error statement states "There is an invalid use of the (.)dot or ! operator or invalid parentheses."  I am now really confused.  Troy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top