473,419 Members | 1,828 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,419 software developers and data experts.

Adding records to a subform from a main form

Hi all,.

I have a small issue I would like to resolve with VBA. I have a form
which
it's fields are bound to a table. Within that form is a subform which
is a
subtable.

Tables relationship is a one to many from the main table to the sub
table.

On the main form I have a "Add Record" button which creates a new
record in
the main table.

What I want to do is put a statement in that Add Record button, on
click
event that will automatically add 20 records to the subtable where the
first
field in the sub form is numberd 1-20.
Obviously I can go to the subform and put in a button that will do
that
using this code(Lane is the first field in the subtable/form):

Me.Lane = 1
DoCmd.GoToRecord , , acNewRec
Me.Lane = 2
DoCmd.GoToRecord , , acNewRec
Me.Lane = 3
DoCmd.GoToRecord , , acNewRec
Me.Lane = 4
DoCmd.GoToRecord , , acNewRec
Me.Lane = 5
DoCmd.GoToRecord , , acNewRec
Me.Lane = 6
DoCmd.GoToRecord , , acNewRec
Me.Lane = 7
DoCmd.GoToRecord , , acNewRec
Me.Lane = 8
DoCmd.GoToRecord , , acNewRec
Me.Lane = 9
DoCmd.GoToRecord , , acNewRec
Me.Lane = 10
DoCmd.GoToRecord , , acNewRec
Me.Lane = 11
DoCmd.GoToRecord , , acNewRec
Me.Lane = 12
DoCmd.GoToRecord , , acNewRec
Me.Lane = 13
DoCmd.GoToRecord , , acNewRec
Me.Lane = 14
DoCmd.GoToRecord , , acNewRec
Me.Lane = 15
DoCmd.GoToRecord , , acNewRec
Me.Lane = 16
DoCmd.GoToRecord , , acNewRec
Me.Lane = 17
DoCmd.GoToRecord , , acNewRec
Me.Lane = 18
DoCmd.GoToRecord , , acNewRec
Me.Lane = 19
DoCmd.GoToRecord , , acNewRec
Me.Lane = 20
But I would prefer my users not have to push 2 buttons for a new
record.
What code would I use to add to the main form's "Add Record" button to
achive
the same results as adding a button and the code directly to the
subform?

Thanks

Sep 21 '07 #1
0 1920

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

Similar topics

1
by: Andante.in.Blue | last post by:
Hi everyone! In Access 97, I have a parent form and a subform that are both based on the same query. The main form is continuous and serves up a summary for each record. The subform provides...
1
by: Mark | last post by:
This question refers to a main form with a continuous form subform. After an error occurs after entering several records in the subform, how can I delete all the data in the main form and all the...
1
by: Richard Hollenbeck | last post by:
I'm getting errors. Access is telling me that it can't add a record. I have a table of college courses and a linked table of groups of activities in that course as a linked table (one course to...
6
by: Wendy Powley | last post by:
I have a subform which represents a 1:N relationship with the main form. I would like to be able to read values from an external file, fill the subform with the values read & allow the user to...
6
by: 6thirty | last post by:
Hi, I've created a stocktaking database using Access XP. This is indexed by two fields - part number and shelf location. I am currently inputting all the data via a form. When I have entered a...
2
by: origin197511 | last post by:
Hello all... I'm having an issue with MSAccess 2000. I have a Form that holds records of my cartridge loads for a rifle and a subform that lists all groups that have been fired with that load. ...
4
by: tlyczko | last post by:
I have been looking on the NGs and I found this code to show if a subform has no records. I have this code in the MAIN form OnClose event: Private Sub btnClose_Click() '4/16/06 new code that...
7
by: Ron | last post by:
Hi All, Using Access2000, winXP. Table 1 = tblClients displayed on frmClients via qryClients. 2nd table = tblInvoices shown on frmInvoices via qryInvoices. 2nd table = tblDetails shown on...
4
by: bkberg05 | last post by:
Hi I have a form called Customer whose record source is a table called Customer. The primary key is Customer_ID. On that form, there's a subform called sub_Customer_Contact_Log. It's record...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.