A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Append Rows based on field value



 
 
Thread Tools Display Modes
  #1  
Old December 9th, 2009, 12:23 AM posted to microsoft.public.access.queries
Bernie
external usenet poster
 
Posts: 125
Default Append Rows based on field value

I would like to have the append query create a fixed number of rows based on
the value from a field value.

For example, field value = 10. I would like my append query to create 10
records.


  #2  
Old December 9th, 2009, 03:36 AM posted to microsoft.public.access.queries
Marshall Barton
external usenet poster
 
Posts: 5,361
Default Append Rows based on field value

Bernie wrote:

I would like to have the append query create a fixed number of rows based on
the value from a field value.

For example, field value = 10. I would like my append query to create 10
records.



You could do that using a VBA procedure and add the rows
through a record set opened on the destination table.

If you want to do it using a query, then create a little
utility table called Numbers with one field named Num.
Populate the table with records containing 1, 2, 3, ... up
to a 100 or whatever.

Then the query could look like:

INSERT INTO destinationtable (f1, f2, ...)
SELECT f1, f2, ...
FROM sourcetable, Numbers
WHERE fx = keyfieldofrecordtoappend
AND Num = fieldvalue

--
Marsh
MVP [MS Access]
  #3  
Old December 9th, 2009, 02:56 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Append Rows based on field value

Table CountNumber field CountNUM has number from 0 (zero) through your
maximum spread.

INSERT INTO YourTable ( ID, SN )
SELECT [Enter item number] AS Expr1, [Enter Starting Serial #]+[CountNUM] AS
Expr2
FROM CountNumber
WHERE (((CountNumber.CountNUM)=[Enter qunaity of records]-1));

--
Build a little, test a little.


"Bernie" wrote:

I would like to have the append query create a fixed number of rows based on
the value from a field value.

For example, field value = 10. I would like my append query to create 10
records.


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:31 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.