Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 06-14-2018, 10:16 AM   #16
DataBass
Newly Registered User
 
Join Date: Jun 2018
Location: Downtown
Posts: 25
Thanks: 14
Thanked 0 Times in 0 Posts
DataBass is on a distinguished road
Re: Automatically create records in subform and nested subform

Uncle Gizmo,

Thanks for taking the time to spell that out. I have not used For Next loops in VBA, but I have used For Each loops in javascript and they appear to be the same thing essentially. Great idea.

I have very limited experience with recordsets. I'm playing with the idea a bit now for setting bookmarks.

Yes, I knew there has to be a better way to make my code work but I just didn't know where to start. Loops and recordsets, will give me plenty to experiment with.

Thanks for your input

DataBass is offline   Reply With Quote
Old 06-14-2018, 10:25 AM   #17
Mark_
Longboard on the internet
 
Join Date: Sep 2017
Posts: 1,176
Thanks: 13
Thanked 221 Times in 219 Posts
Mark_ will become famous soon enough
Re: Automatically create records in subform and nested subform

If categories belong to stages, then looking up the category will get you the stage ID. You don't need to save it.
Mark_ is offline   Reply With Quote
Old 06-14-2018, 09:49 PM   #18
JHB
Have been here a while
 
Join Date: Jun 2012
Location: In the south of Denmark (Jutland), near the German border.
Posts: 7,123
Thanks: 2
Thanked 1,904 Times in 1,862 Posts
JHB has a spectacular aura about JHB has a spectacular aura about
Re: Automatically create records in subform and nested subform

Do the attached database now fulfilled you requirement?
Else explain where it is wrong, (printscreen)!
Attached Files
File Type: accdb Database57.accdb (504.0 KB, 17 views)

__________________
If the above post has helped you, why not take the time to say thank you, by pressing the "Thumbs up."
JHB is offline   Reply With Quote
The Following User Says Thank You to JHB For This Useful Post:
DataBass (06-15-2018)
Old 06-15-2018, 01:54 PM   #19
DataBass
Newly Registered User
 
Join Date: Jun 2018
Location: Downtown
Posts: 25
Thanks: 14
Thanked 0 Times in 0 Posts
DataBass is on a distinguished road
Re: Automatically create records in subform and nested subform

JHB,

Amazing. That did it. I'm going to dig into your sample and figure out how you did that.

This is great.

THANK YOU!!

Where should I send the beer?

Last edited by DataBass; 06-15-2018 at 02:02 PM.
DataBass is offline   Reply With Quote
Old 06-15-2018, 06:20 PM   #20
JHB
Have been here a while
 
Join Date: Jun 2012
Location: In the south of Denmark (Jutland), near the German border.
Posts: 7,123
Thanks: 2
Thanked 1,904 Times in 1,862 Posts
JHB has a spectacular aura about JHB has a spectacular aura about
Re: Automatically create records in subform and nested subform

Quote:
Originally Posted by DataBass View Post
Amazing. That did it. I'm going to dig into your sample and figure out how you did that.
..THANK YOU!!

Where should I send the beer?
The StageID is coming from the tblActivity, (so no magic at all)!
You're welcome!
Send it to Denmark, (prefer a cold Tuborg from the bottle).
__________________
If the above post has helped you, why not take the time to say thank you, by pressing the "Thumbs up."
JHB is offline   Reply With Quote
Old 06-15-2018, 07:28 PM   #21
DataBass
Newly Registered User
 
Join Date: Jun 2018
Location: Downtown
Posts: 25
Thanks: 14
Thanked 0 Times in 0 Posts
DataBass is on a distinguished road
Re: Automatically create records in subform and nested subform

This should keep you happy for a while



Thanks again

Last edited by DataBass; 06-15-2018 at 08:54 PM.
DataBass is offline   Reply With Quote
Old 06-16-2018, 11:07 PM   #22
DataBass
Newly Registered User
 
Join Date: Jun 2018
Location: Downtown
Posts: 25
Thanks: 14
Thanked 0 Times in 0 Posts
DataBass is on a distinguished road
Re: Automatically create records in subform and nested subform

I've run into an interesting problem.

When I adapt this method to my current project I get an error when doing the append queries on a totally new record on the main form. It works fine if I append to an Item that previously existed.
It says it failed to append the records due to primary key violations. If I save the main record first, then append, it works.

Any idea why this might be happening? I'm guessing I need to start with fresh tables with no data because JHB's example works perfectly.

DataBass is offline   Reply With Quote
Old 06-17-2018, 03:08 AM   #23
JHB
Have been here a while
 
Join Date: Jun 2012
Location: In the south of Denmark (Jutland), near the German border.
Posts: 7,123
Thanks: 2
Thanked 1,904 Times in 1,862 Posts
JHB has a spectacular aura about JHB has a spectacular aura about
Re: Automatically create records in subform and nested subform

It happens because the value from ItemID isn't in the table for new created records, (until it is saved).
How do you add/create the records in the subform, click a button or how?
__________________
If the above post has helped you, why not take the time to say thank you, by pressing the "Thumbs up."
JHB is offline   Reply With Quote
Old 06-17-2018, 11:59 AM   #24
DataBass
Newly Registered User
 
Join Date: Jun 2018
Location: Downtown
Posts: 25
Thanks: 14
Thanked 0 Times in 0 Posts
DataBass is on a distinguished road
Re: Automatically create records in subform and nested subform

The new records are added as part of the After Update event when the cboItemType combo box is changed.
I forced it to save the record and it works, but I didn't think I should have to do that because your example works without saving the record.
DataBass is offline   Reply With Quote
Old 06-17-2018, 09:29 PM   #25
JHB
Have been here a while
 
Join Date: Jun 2012
Location: In the south of Denmark (Jutland), near the German border.
Posts: 7,123
Thanks: 2
Thanked 1,904 Times in 1,862 Posts
JHB has a spectacular aura about JHB has a spectacular aura about
Re: Automatically create records in subform and nested subform

Maybe I can make a working without saving the record, if you post your database with some sample data, (I need the database because it is to much guessing how you've set it up).
__________________
If the above post has helped you, why not take the time to say thank you, by pressing the "Thumbs up."
JHB is offline   Reply With Quote
Old 06-18-2018, 10:28 AM   #26
DataBass
Newly Registered User
 
Join Date: Jun 2018
Location: Downtown
Posts: 25
Thanks: 14
Thanked 0 Times in 0 Posts
DataBass is on a distinguished road
Re: Automatically create records in subform and nested subform

Thanks JHB,

I will post something later.

Do you have any idea why this isn't a problem with the sample database that you posted?

DataBass is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Create automatically records into subform jealindgar General 5 01-07-2008 08:37 AM
Automatically Create Records in Subform hootie318 Forms 15 04-28-2006 12:04 PM
[SOLVED] Automatically add records to a subform jephrey Modules & VBA 0 02-08-2006 12:51 PM
How to automatically create rows in a subform ? novoiceleft Forms 0 07-27-2004 02:13 AM
Add subform records automatically. StefanSch Forms 1 03-25-2003 02:03 PM




All times are GMT -8. The time now is 08:28 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World