Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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?
Reply With Quote
  #2 (permalink)  
Old April 9th, 2010, 08:17 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
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
Reply With Quote
  #3 (permalink)  
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:21 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.