Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 26th, 2010, 06:04 PM
Authorized User
 
Join Date: Mar 2010
Posts: 10
Thanks: 1
Thanked 0 Times in 0 Posts
Default acNewRec - Update additional fields

I have a form that will query a table called tbl_Schedules.
Code:
tbl_Schedules defined as:
   field1
   field2
   field3
On this form is a subform that has as its RecordSource a query of tbl_Schedules.
Code:
SELECT field2, field3 FROM tbl_Schedules WHERE field1 = Day.value;
The subform only displays a subset of the fields from tbl_Schedules. On the subform, i have a command button that will add a new record into tbl_Schedules.

This action is handled by
Code:
' can i set fields before issuing new record??
DoCmd.GoToRecord , , acNewRec
HOWEVER, i need to update a field that is not explicitly shown on the subform, namely field1.

How can I do this?
 
Old April 9th, 2010, 08:17 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

The subform should not contain a query of the same table as the main form. There should be two tables with primary and foreign keys (PK and FK) linking the two in a (usually) one-to-many relationship. Then as you scroll through the main form, the subform (linked via parent/child property) will change based on the keys. You don't change the child Field1 in the subform ever. You change parent Field1 in the main form and that changes the child Field1 in the subform.

So you should have tbl_Schedules with Field1 (PK), Field2, Field3; and you should have tbl_Other with Field4 (PK), Field1 (FK), Field5, Field6, etc.
__________________
Greg Serrano
Michigan Dept. of Environmental Quality
Air Quality Division
 
Old May 4th, 2010, 06:06 PM
Authorized User
 
Join Date: Mar 2010
Posts: 10
Thanks: 1
Thanked 0 Times in 0 Posts
Default Re: acNewRec - Update additional fields

Thanks SerranoG, i appreciate the reply and suggestion.

I believe I have solved what I needed. I made hidden fields on the subform and passed the results of a query (that includes the fields i need) in the RecordSource of the subform.

So, although the user cannot see those fields/values, the values and more importantly the fields that need to be updated are readily available.

Best regards,
D





Similar Threads
Thread Thread Starter Forum Replies Last Post
DoCmd.GoToRecord , , acNewRec doesnt create new re david_bridges Access VBA 1 August 21st, 2006 06:03 AM
update a fields value Vince_421 Access VBA 2 May 19th, 2006 06:41 AM
Update Table fields karajian Access VBA 2 December 7th, 2004 03:48 PM
Update multiple fields. slgknjn Classic ASP Databases 6 February 15th, 2004 10:26 AM
fields from tables to update damnnono_86 Access 3 November 5th, 2003 04:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.