Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 1st, 2004, 08:05 AM
jfalexan jfalexan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 3 jfalexan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 14 sec
Reputation Power: 0
Post Creating detail records in a form from table query

I am developing a contracts tracking database. Many contracts share a common set of deliverables. I have created a table that stores the list of deliverables that are common to many contracts. In a form I would like to select the deliverable class from the DeliverablesDefinition table which stores the individual lines to be created for a given contract. I would like to have a button on the form that will read the selected deliverable class, query the deliverable class table and insert the specified rows into the ContractsDeliverable table. In effect I am trying to pre-fill the form with a set of records queried from another table where the select critera are defined in the form.

Reply With Quote
  #2  
Old December 1st, 2004, 08:33 AM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 4
Hi jfalexan,

I would create a combobox that has a rowsource set to your table DeliverablesDefinition. Include all the fields that you want to add to your form. Then in the AfterUpdate of the combobox, you can add some basic code:

Field1.Value = combobox.Column(1)
Field2.Value = combobox.Column(2)

Typically the first column of the combobox is your Primary ID and it will always be Column (0)

This would fill in the fields on your form with the desired information from your table based on what was selected in the combobox.

lwells

Reply With Quote
  #3  
Old December 1st, 2004, 08:39 AM
jfalexan jfalexan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 3 jfalexan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 14 sec
Reputation Power: 0
lwells,

Thanks for the reply. The portion of the form that I am trying to fill is a subform that is in datasheet form and can have n-number of rows. Each row has about 10 columns. I thought that it would be easiest to click a button that would insert records into the table and then requery the subform. I am not sure how to write the insert into statment (I know the syntax for the the statement) into an event, if this is the right approach. This is my first time working with access forms and events.

Jim.

Quote:
Originally Posted by lwells
Hi jfalexan,

I would create a combobox that has a rowsource set to your table DeliverablesDefinition. Include all the fields that you want to add to your form. Then in the AfterUpdate of the combobox, you can add some basic code:

Field1.Value = combobox.Column(1)
Field2.Value = combobox.Column(2)

Typically the first column of the combobox is your Primary ID and it will always be Column (0)

This would fill in the fields on your form with the desired information from your table based on what was selected in the combobox.

lwells

Reply With Quote
  #4  
Old December 1st, 2004, 09:13 AM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 4
Hi Jim,

Understand. Are you trying to inserting multiple records at one time or is this just one record inserted into your subform after you make your selection? Either way can be done.

What I would do is to test out using the append query method. First create the query that will have the records based on whatever you select from your form. Use this query in the append query to insert the records into the table that your subform is based on. The button on your form would execute this query and then requery the subform to reflect the new records that were added.

If you would rather have all this in vba code without the physical query objects, it can be done by making a temporary recordset of the records based on your criteria and then inserting those records into a recordset of the table. This method is a little more complex, but can be done that way as well.

lwells

Reply With Quote
  #5  
Old December 1st, 2004, 11:36 AM
jfalexan jfalexan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 3 jfalexan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 14 sec
Reputation Power: 0
Red face

lwells,



Thanks for the additional information. I will look at this later today. I truly appreciate your time and expertice. I understood all of the concepts you presented. Execution may be another story.

Thanks again,

Jim.

Quote:
Originally Posted by lwells
Hi Jim,

Understand. Are you trying to inserting multiple records at one time or is this just one record inserted into your subform after you make your selection? Either way can be done.

What I would do is to test out using the append query method. First create the query that will have the records based on whatever you select from your form. Use this query in the append query to insert the records into the table that your subform is based on. The button on your form would execute this query and then requery the subform to reflect the new records that were added.

If you would rather have all this in vba code without the physical query objects, it can be done by making a temporary recordset of the records based on your criteria and then inserting those records into a recordset of the table. This method is a little more complex, but can be done that way as well.

lwells

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > Creating detail records in a form from table query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway