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

Field not updating on table from subform

Status
Not open for further replies.

modglin

Programmer
Apr 10, 2001
105
I have a table named CardPerspective and a table named Objective. I have the tables linked by a field called PerpectiveKey.
When I enter data into the form Perspective_ObjectiveData it saves the data on the CardPerspective table. When I enter data into the form ObjectiveSubform, in the control source for Perspective Key I have:
=Forms!Perspective_ObjectiveData!Perspective_Key
It populates the field in the subform from the main form, however, after entering the rest of the data into the subform, it does not enter the perspectivekey data into the table Objective.
Hope I explained that enough.
Any help would be greatly appreciated.
 
I didn't think to mention that the second form is not actually a subform it was on my first version of the database, but now I have it set up that you fill in the information on the Perspective_ObjectiveData form and then click a command buttont that opens the ObjectiveSubForm which has the the Perspective_key from the first form using the =Forms!Perspective_ObjectiveData!Perspective_Key. I did not like the looks of the form with all the sub forms in it
 
Is the second form bound to the Objective table?
 
The Record Source is Objective and the filter is PerspectiveKey = "Acct01" (which is the Perpective I was on in the first form that I had open before clicking open Objectives form.)
 
I am not quite sure what you are trying to do, but I think you should be opening your form a bit like this:
[tt]DoCmd.OpenForm "ObjectiveSubForm", , , , acFormAdd, , Me.Perspective_Key[/tt]
Which will open the form at a new record. The final argument is an OpenArg which can be used to fill in the appropriate field. I do not think p=that putting =Forms!Perspective_ObjectiveData!Perspective_Key as a control source is a good idea. If I have missed your point, please post your code, which will help me (and others) see what you want to do.
 
How are ya modglin . . . . .
modglin said:
[blue]It populates the field in the subform from the main form, however, after entering the rest of the data into the subform, [purple]it does not enter the perspectivekey data into the table Objective.[/purple][/blue]
Thats because [blue]=Forms!Perspective_ObjectiveData!Perspective_Key[/blue] makes [blue]Perspective_Key[/blue] on ObjectiveSubForm [purple]UnBound![/purple]

To correct this:
[ol][li]Set the [blue]ControlSource[/blue] for Perspective_Key to the [purple]proper fieldname[/purple] (textbox is now bound).[/li]
[li]Then in the [blue]Load[/blue] event of [blue]ObjectiveSubForm[/blue], something like:
Code:
[blue]   DoCmd.RunCommand acCmdRecordsGoToNew
   Me!Perspective_Key = Forms!Perspective_ObjectiveData!Perspective_Key[/blue]
[/li][/ol]

Calvin.gif
See Ya! . . . . . .
 
Thanks! I actually tried that something like that last week and it didn't work for me, however, I had a second field that had to be populated when I created a new record so I may not have had an AND in the code I really don't remember. Anyway, this is what I tried today and it worked:
Code:
DoCmd.GoToRecord , , acNewRec
    Me.PerspectiveKey = Forms!Perspective_ObjectiveData!Perspective_Key
    Me.ObjectiveKey = Left(Me.PerspectiveKey, 8) & "0" & DCount("*", "Objective") + 1
[2thumbsup] Thank you both for your help!!!!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top