Generate multiple records

Catalina

Registered User.
Local time
Yesterday, 19:24
Joined
Feb 9, 2005
Messages
471
A search didn't help me find the solution.
Hopefully somenone will help me out.

This is what I like to accomplish.
On the Main Form (based on table "MyDay") there is a Subform
(based on table "MyHours"), linked one to many.

Now when I create a new 'Day' I like to automatically generate
12 records in the subform, with the 'Hour' field filled in
06.00, 07.00 etc.

All help will be greatly appreciated.
 
If the subform records do not exist, generate then with DAO or ADO code and then requery the subform.
 
Catalina said:
A search didn't help me find the solution.
Hopefully somenone will help me out.

This is what I like to accomplish.
On the Main Form (based on table "MyDay") there is a Subform
(based on table "MyHours"), linked one to many.

Now when I create a new 'Day' I like to automatically generate
12 records in the subform, with the 'Hour' field filled in
06.00, 07.00 etc.

All help will be greatly appreciated.

There are several ways to tackle this issue, this is just one of them:

Create a table with one colum (date/time) and imput the hours you want to appear (06:00AM, 07:00AM...etc)

Make a button on your Main Form.

Create a query that append the hours and take the Primary Key on the form for the table.

Run the append query and requery subform on the on click event of the button.

See Attached -- Open the Db and go to the form...
 

Attachments

Last edited:
Thanks

Thanks guys for the help.

Gabriel,your solution works just great.
I appreciate you taking the time to make the sample.

Catalina
 
I like to automatically generate 12 records in the subform
- 1. Subforms don't store records, tables store records.
2. Since you are prepopulating the subform's RecordSource, you should probably set AllowAdditions to No and AllowDeletions to No since the user shouldn't be adding and deleting records via the subform.
 
Yeah, Pat, you know a lot of tricks. Great advice.
 

Users who are viewing this thread

Back
Top Bottom