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  

create append query resulting in multiple new records



 
 
Thread Tools Display Modes
  #1  
Old October 13th, 2009, 04:35 AM posted to microsoft.public.access.queries
8l2255
external usenet poster
 
Posts: 11
Default create append query resulting in multiple new records

I have a new transaction form. It has fields TransactionID (autonumber),
ProductID, EquipmentID, UnitsReceived and a few more. When I create a new
transaction record I would like the TransactionID, ProductID and EquipmentID
to append new records to the amount of UnitsReceived in my Stock table.

Is it possible for an append query to create multiple new records using
information in the new transaction record and is it possible for the number
of records to correspond with the value entered for UnitsReceived?
  #2  
Old October 13th, 2009, 02:25 PM posted to microsoft.public.access.queries
Tedmi
external usenet poster
 
Posts: 141
Default create append query resulting in multiple new records

It is possible by using an INSERT statement in a loop in the AfterInsert
event of the transaction form. The numer of iterations of the loop would be
the value of UnitsReceived. But why?
Do you really want to have a separate record for each received item?
Wouldn't it suffice to have a single record in the Stock Table, with a field
holding the OnHand quantity? Then, the AfteInsert event of the transaction
can merely update the appropriate record in the stock table:
UPDATE StockTable SET OnHandQ = OnHandQ+Me.UnitsReceived
WHERE ProductID=Me.ProductID AND EquipmentID=Me.EquipmentID

(assuming that the Stock table has fields ProductID and EquipmentID as
unique compound key)

-TedMi

"8l2255" wrote in message
...
I have a new transaction form. It has fields TransactionID (autonumber),
ProductID, EquipmentID, UnitsReceived and a few more. When I create a new
transaction record I would like the TransactionID, ProductID and
EquipmentID
to append new records to the amount of UnitsReceived in my Stock table.

Is it possible for an append query to create multiple new records using
information in the new transaction record and is it possible for the
number
of records to correspond with the value entered for UnitsReceived?



  #3  
Old October 13th, 2009, 05:10 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default create append query resulting in multiple new records

You can use a Cartesian effect append query.
Creacte a table named CountNumber with number field name CountNUM containing
0 (zero) through your maximum.
Create the append query, add the CountNumber table, drag the CountNUM field
to the FIELD row, add criteria --
Between 1 AND [Forms]![YourFormName]![UnitsReceived]

--
Build a little, test a little.


"8l2255" wrote:

I have a new transaction form. It has fields TransactionID (autonumber),
ProductID, EquipmentID, UnitsReceived and a few more. When I create a new
transaction record I would like the TransactionID, ProductID and EquipmentID
to append new records to the amount of UnitsReceived in my Stock table.

Is it possible for an append query to create multiple new records using
information in the new transaction record and is it possible for the number
of records to correspond with the value entered for UnitsReceived?

  #4  
Old November 13th, 2009, 12:30 AM posted to microsoft.public.access.queries
8l2255
external usenet poster
 
Posts: 11
Default create append query resulting in multiple new records

@Tedmi
Each individual item has a transfer location which needs to be recorded. As
I am VERY new to access I am positive there is a better way but I am not sure
how.
@Karl Dewey
hmmm. I am still having trouble with this. am focussing on another problem.

thanks for your help.

"KARL DEWEY" wrote:

You can use a Cartesian effect append query.
Creacte a table named CountNumber with number field name CountNUM containing
0 (zero) through your maximum.
Create the append query, add the CountNumber table, drag the CountNUM field
to the FIELD row, add criteria --
Between 1 AND [Forms]![YourFormName]![UnitsReceived]

--
Build a little, test a little.


"8l2255" wrote:

I have a new transaction form. It has fields TransactionID (autonumber),
ProductID, EquipmentID, UnitsReceived and a few more. When I create a new
transaction record I would like the TransactionID, ProductID and EquipmentID
to append new records to the amount of UnitsReceived in my Stock table.

Is it possible for an append query to create multiple new records using
information in the new transaction record and is it possible for the number
of records to correspond with the value entered for UnitsReceived?

  #5  
Old November 26th, 2009, 05:04 AM posted to microsoft.public.access.queries
8l2255
external usenet poster
 
Posts: 11
Default create append query resulting in multiple new records

I finally came back to this today,

I created a form with
CategoryID
ProductID
Date_Acquired
StatusID
and a qty box called txtN

When i click create_lot it appends txtN amount of item records with info as
filled out in the form to my itemtbl.


Private Sub Create_Lot_Click()

Dim db As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("itemtbl")
With rs
For a = 1 To TxtN
..AddNew
!ProductID = ProductID
!CategoryID = CategoryID
!StatusID = 1
!Date_Aquired = Date_Aquired
..Update
Next a
End With
rs.close

End Sub

"TedMi" wrote:

It is possible by using an INSERT statement in a loop in the AfterInsert
event of the transaction form. The numer of iterations of the loop would be
the value of UnitsReceived. But why?
Do you really want to have a separate record for each received item?
Wouldn't it suffice to have a single record in the Stock Table, with a field
holding the OnHand quantity? Then, the AfteInsert event of the transaction
can merely update the appropriate record in the stock table:
UPDATE StockTable SET OnHandQ = OnHandQ+Me.UnitsReceived
WHERE ProductID=Me.ProductID AND EquipmentID=Me.EquipmentID

(assuming that the Stock table has fields ProductID and EquipmentID as
unique compound key)

-TedMi

"8l2255" wrote in message
...
I have a new transaction form. It has fields TransactionID (autonumber),
ProductID, EquipmentID, UnitsReceived and a few more. When I create a new
transaction record I would like the TransactionID, ProductID and
EquipmentID
to append new records to the amount of UnitsReceived in my Stock table.

Is it possible for an append query to create multiple new records using
information in the new transaction record and is it possible for the
number
of records to correspond with the value entered for UnitsReceived?




 




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 12:46 PM.


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