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

Adding Multiple Records

Ok, this may turn out to be longwinded, so pelase bare with me...

I am working on an inventory/stock control database for the IT systems
in the school I work at. I currently have two tables that deal with
printer consumables that I am trying to work with:

tblCartridgeType which holds the details for the model of cartridge
tblCartridges which holds a record for each cartridge we have in stock.

tblCartridgeType has a "Name" field (text) which holds our name for the
cartridge model and tblCartridges has a "CartridgeType" field (number)
which is related to tblCartridgeType's autonumber field (primary key).

What I am trying to do is create a form where I can select a cartridge
type from a drop down list (cboCartType) and then select a number from
a second list which relates to the number of records to add (ie, the
number of cartridges of that type to add to stock). When I click the
add button, I want Access to add that number of records into
tblCartridges, all with the CartridgeType field set to the value of
cboCartType. (Have I lost you yet... :P )

I thought it could be done with an Append query, but I just can't
figure out how. Also, I'm not to hot on VBA so I haven't been able to
figure out how to do it that way either.

Any help would be very greatly appreciated!

RobC.

Nov 13 '05 #1
1 7303
Br
gr****@cowannet.com wrote:
Ok, this may turn out to be longwinded, so pelase bare with me...

I am working on an inventory/stock control database for the IT systems
in the school I work at. I currently have two tables that deal with
printer consumables that I am trying to work with:

tblCartridgeType which holds the details for the model of cartridge
tblCartridges which holds a record for each cartridge we have in
stock.

tblCartridgeType has a "Name" field (text) which holds our name for
the cartridge model and tblCartridges has a "CartridgeType" field
(number) which is related to tblCartridgeType's autonumber field
(primary key).
Don't use reserved words for field/object names. Use something like
"CartridgeName".
What I am trying to do is create a form where I can select a cartridge
type from a drop down list (cboCartType) and then select a number from
a second list which relates to the number of records to add (ie, the
number of cartridges of that type to add to stock). When I click the
add button, I want Access to add that number of records into
tblCartridges, all with the CartridgeType field set to the value of
cboCartType. (Have I lost you yet... :P )

I thought it could be done with an Append query, but I just can't
figure out how. Also, I'm not to hot on VBA so I haven't been able to
figure out how to do it that way either.

Any help would be very greatly appreciated!

RobC.


Sounds like you just need a simple loop...

Dim i as Long, myRS as Recorset
Set myRS = CurrentDB.OpenRecordset("tblCartridges")
For i = 1 to Me![NumberOfCartridges]
With myRS
.AddNew
![CatridgeTypeID] = Me![CatridgeTypeID]
' NOTE: you don't need to hold the value of the name as you can
just look it up from the ID
.Update
End With
Next

--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #2

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

Similar topics

6
by: Jamie Fryatt | last post by:
Hi everyone, here's what id like to do. I have a table with 2 fields, name and value I need to be able to add multiple records quickly, for example I need to add name value abc 1...
1
by: mellie | last post by:
Hi there, SQL 2000 database with ASP I've found many things "out there" regarding updating and deleting multiple records with checkboxes but I can't seem to find anything about adding them. ...
2
by: dixie | last post by:
I have a report which is printed daily. It is a list of people. A person can be put on this list for one day, which is easyily achieved from a simple form. My problem is that a person can also...
6
by: Robin S. | last post by:
**Eric and Salad - thank you both for the polite kick in the butt. I hope I've done a better job of explaining myself below. I am trying to produce a form to add products to a table (new...
4
by: Mike Hnatt | last post by:
My goal is to get data from an XML file into a couple of tables in an Access database. The XML file is a little complex so I need control over what I do (I can't just read it into a dataset). ...
1
by: Andrew | last post by:
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest project has me kinda stumped and after a couple...
8
by: shumaker | last post by:
I'm wondering if adding an autonumber primary key will improve the performance of a multiuser access database on a network share. I have a website that lists many tips for improving performance of...
1
by: access345 | last post by:
I am trying to add a record to multiple tables at the same time. My current Code created multiple records in the same table. I am trying two different methods with no results: Public Sub...
2
by: Kosmos | last post by:
Alright so I've got this Outlook code written in VBA in Access. The first part, which works, records information about appointment times based on the required days before notification of certain...
0
by: EricLondaits | last post by:
Hi, I have an ASP.NET page with a ListBox that is data bound to a table with a single field (it holds a list of valid IDs). The page also has a textBox into which you can add new valid IDs, one...
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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...

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.