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  

Update records in subform with value from main form



 
 
Thread Tools Display Modes
  #1  
Old September 17th, 2009, 03:32 PM posted to microsoft.public.access.forms
Darrell Childress[_2_]
external usenet poster
 
Posts: 17
Default Update records in subform with value from main form

I have a form (frmPOReq_Header) with a field called ReqdDate. Then there
is a subform (frmPOReq_Detail) where we add line items. When entering
records on the subform the ReqdDate defaults to the value of ReqdDate on
the main form. I would like to be able to go back in later and change
the ReqdDate on the main form and then update all the line items on the
subform with that new date. I guess the best way to do this would be
click a button to "update" the ReqdDate field for records on the
subform. Need help with code.
Thanks,
Darrell
  #2  
Old September 17th, 2009, 03:48 PM posted to microsoft.public.access.forms
ronytimm
external usenet poster
 
Posts: 11
Default Update records in subform with value from main form

Just run an update query.
create new query with the underlying table which need to be updated and in
the criteria of the field to be updated link to the ReqDate in the main form.
Call the query by property after update or make a button as you suggest with
code on click Docmd.openqyery "name_of_query"
rgds

R.


"Darrell Childress" wrote:

I have a form (frmPOReq_Header) with a field called ReqdDate. Then there
is a subform (frmPOReq_Detail) where we add line items. When entering
records on the subform the ReqdDate defaults to the value of ReqdDate on
the main form. I would like to be able to go back in later and change
the ReqdDate on the main form and then update all the line items on the
subform with that new date. I guess the best way to do this would be
click a button to "update" the ReqdDate field for records on the
subform. Need help with code.
Thanks,
Darrell

  #3  
Old September 17th, 2009, 06:54 PM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Update records in subform with value from main form

On Thu, 17 Sep 2009 10:32:56 -0400, Darrell Childress
wrote:

I have a form (frmPOReq_Header) with a field called ReqdDate. Then there
is a subform (frmPOReq_Detail) where we add line items. When entering
records on the subform the ReqdDate defaults to the value of ReqdDate on
the main form. I would like to be able to go back in later and change
the ReqdDate on the main form and then update all the line items on the
subform with that new date. I guess the best way to do this would be
click a button to "update" the ReqdDate field for records on the
subform. Need help with code.
Thanks,
Darrell


Well... that would be very bad design, I fear. You're storing ReqdDate
redundantly, in two different tables, so there is no automatic way to ensure
that the values in the two tables agree.

I would suggest removing the field from the detail table altogether, and just
linking to the parent table to determine the value of the date.

If that doesn't meet your needs please explain why.
--

John W. Vinson [MVP]
  #4  
Old September 17th, 2009, 08:27 PM posted to microsoft.public.access.forms
Darrell Childress[_2_]
external usenet poster
 
Posts: 17
Default Update records in subform with value from main form

Thanks John for the response. I do need to store the data in two
different tables and here's why. The user fills in the header info with
misc info, including the ReqdDate (Required Date). When they enter the
line items, I have the ReqdDate for the items default to whatever is on
the header, but the user can change that if necessary because one item
may be needed on 9/17 and another may not be needed until 9/19. In at
least 95% (probably 99%) of the cases, all items are needed the same date.
I suppose I could always not actually store the ReqdDate in the header
table and use an unbound field on the form merely to use as a default
for the detail items.

John W. Vinson wrote:
On Thu, 17 Sep 2009 10:32:56 -0400, Darrell Childress
wrote:

I have a form (frmPOReq_Header) with a field called ReqdDate. Then there
is a subform (frmPOReq_Detail) where we add line items. When entering
records on the subform the ReqdDate defaults to the value of ReqdDate on
the main form. I would like to be able to go back in later and change
the ReqdDate on the main form and then update all the line items on the
subform with that new date. I guess the best way to do this would be
click a button to "update" the ReqdDate field for records on the
subform. Need help with code.
Thanks,
Darrell


Well... that would be very bad design, I fear. You're storing ReqdDate
redundantly, in two different tables, so there is no automatic way to ensure
that the values in the two tables agree.

I would suggest removing the field from the detail table altogether, and just
linking to the parent table to determine the value of the date.

If that doesn't meet your needs please explain why.

  #5  
Old September 18th, 2009, 06:29 AM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Update records in subform with value from main form

On Thu, 17 Sep 2009 15:27:28 -0400, Darrell Childress
wrote:

Thanks John for the response. I do need to store the data in two
different tables and here's why. The user fills in the header info with
misc info, including the ReqdDate (Required Date). When they enter the
line items, I have the ReqdDate for the items default to whatever is on
the header, but the user can change that if necessary because one item
may be needed on 9/17 and another may not be needed until 9/19. In at
least 95% (probably 99%) of the cases, all items are needed the same date.
I suppose I could always not actually store the ReqdDate in the header
table and use an unbound field on the form merely to use as a default
for the detail items.


I think that would be the prudent approach. Having two different ReqdDate
fields in related tables will be confusing at some point!
--

John W. Vinson [MVP]
 




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 01:19 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.