473,387 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

auto populate sub datasheet

DSR
Can anyone tell me how to do this? I have a table (TableBuildings) that
I want to auto create data to its sub datasheet (TableDaysOfWeek)
whenever a new record is added to the parent table (one to many). The
data that I want to auto create is each day of the week (Mon - 1st
record, Tue - 2nd record, Wed 3rd record ... etc) each as its own
record. Each of these records will be unique based on an auto number ID
field in that table. Therefore each day will have its own sub datasheet
(in a one to many relationship). The reason I want to automate the
values in this table is because I don't want the user to have to
enter the days for every new record since there will be many entries. I
am thinking that I will accomplish all of this with an event on my form
the first table is populated with. Could someone please put me on the
right track on how to approach this?

Thanks Dave

Jan 28 '06 #1
1 3263
Haven't tested this and it's off the top of my head but:-

It would seem the best place to do this is the after insert event on
the main form.

Dim DoWeek as adodb.recordset
Dim i as Integer

Dim DayArray(7) = as string

DayArray(1) = "Sunday"
DayArray(2) = "Monday"
' you can fill in the rest

set DoWeek = new adodb.recordset
DoWeek.open "Select * from TableDaysOfWeek",
currentproject.connection,adOpenKeyset, adLockOptimistic

with DoWeek
for i = 1 to 7
.Addnew
' dont have to wory about the autonumber key of DaysOfWeek Table
!BuildingId = me!BuildingId '(whatever is the key of
TableBuildings)
!Day = DayArray(i)
' fill in values of any other fields
.Update
next i
end with

'If you have days of week show in a subform you might need
SubformName.Requery (not sure about this without testing)

Jan 31 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: C. David Rossen | last post by:
Hello: I have a registration form for classes. Each class has a fee. I have a drop down box whereby the user chooses his class. There is a textbox with the associated fee. I would like to...
1
by: ogilby1 | last post by:
Using an immediate if to fill a field on a form based on the value of another field. During data entry on the form this methodology works well. When looking at the results in the datasheet view or...
1
by: Angela Byars | last post by:
I imported several .dbf's from another application to use as the basis for my form. In addition to displaying the records that were created with the original application my users will be adding...
5
by: Geoff Portbury | last post by:
I'm a swimming club coach. I have a data base for recording times at various meets. I have a FORM for entering times called SWIM TIMES. When I enter the swimmers name ID, eg FOR01 for Doug Ford I...
5
by: chrisse_2 | last post by:
Hi, I need some help. I have created a form where there are 3 combo boxes and a text box to search through records. Based on what the user fills in, you then it a "go" button to run the query...
1
by: Jason Galvin | last post by:
I would like to disable the auto-populating feature (remembers form element text between post-backs) when creating a .NET form. I have succeeded in disabling auto-populate by creating my controls...
5
by: joshua.nicholes | last post by:
I have an access database that consists of two tables.A data collection table and a species list table. The data collection table has about 1500 records in it and the species list has about 600....
6
by: Savita23 | last post by:
I am trying to pass a query string from the main form to subform to display records in datasheet view.I tried using the following code in the form_load() event to populate the subform(Child0) ...
2
by: paulyXvpf | last post by:
Hi All, FACTS: > I've created a VB.NET 2005 form, with a SQL Server 2000 backend > The form has about 30 fields that populate 30 columns in the SQL database > The form has mostly text feilds,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.