By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,679 Members | 2,763 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,679 IT Pros & Developers. It's quick & easy.

Adding selected records to a New Table...

P: n/a
Hi,

I have an order form which has a field 'ProductID'.
This form has a button on each record to open a new form linked by
ProductID.
This new form is a continuous form and obviously, only displays the
records associated with that ProductID.

Basically this is part of a Product Packing Pick System. From my
products table, each product has a set default amount of items which
need to be packed. What I am trying to do is:

When a customer places an order, our users can bring up the packing
list associated to the ordered product and either select/de-select
certain items, depebding on the customers requirements.

On this pop-up form linked by ProductID, there may be six (6) items
listed. On this continuous form the user may select/de-select any line
item by pressing a button on each record. The button simply changes
another field on each record from YES to NO.

I then have a button at the bottom of the form which runs an APPEND
Query to only add the records displayed as YES to my new table. This
new table will hold the selected packing items for future reference
until the order has been shipped etc.

My code works, except it appends all the records (six) six times,
rather than starting on the first record, adding it to the new table,
move to the next and so on. It adds all six, then repeats itself for
however many records there are ?

My code under the button is:

__________________________________

Dim rst As DAO.Recordset
Dim n As Integer

Set rst = Forms!ProductPackSelectorF.RecordsetClone
rst.MoveLast
n = rst.RecordCount
rst.MoveFirst
Do Until rst.EOF

Me.Text32.SetFocus
If Me.Text32.text = "Y" Then

Dim stDocName As String

stDocName = "PackingSelectorREC"
DoCmd.OpenQuery stDocName, acNormal, acEdit ('Append Query)

End If

rst.MoveNext

Loop

____________________________________________
The fields on the new table have exactly the same name, so all I want
is a button on the form to add only the selected records marked 'YES'.
Each product ordered by the customer is marked with a JOB NUMBER. This
also needs to be recorded with each record.

The idea being that in future I can search for a Job Number and pull
up the Recordered Packing Items.

Appreciate your help on this. Maybe there is a better way to add
records one by one rather than using an Append Query in a loop.
Thanks
David.
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
da***@scene-double.co.uk (David) wrote:
My code works, except it appends all the records (six) six times,
rather than starting on the first record, adding it to the new table,
move to the next and so on. It adds all six, then repeats itself for
however many records there are ?


Hi David,

Have you considered using a select query which filters for the 'Yes'
condition instead of duplicating your data?

Regards,
Keith.
Nov 13 '05 #2

P: n/a

Keith,

Thanks for responding.
Let me explain further. I have a Table: Products
I also have a table: ProductPack

Products (1 to many) ProductPack.
ProductPack only contains the Packing Items for that product, linked via
productID.

In the Order Processing part of my order, when we enter an order for a
customer, we bring up a 'Job Number' for that new orderline and select
the Product. We can then hit a button which brings up a continuous form
listing all the packing items for that product. This form is based on a
query, based on the table ProductPack, with ProductID criteria set.

On the pop up form from the orders section, we can select yes/no against
each packing item.

I now need to record these selections for each Job Number not ProductID.
So, in the table ProductPack there will only be 'x' packing items for
each product.

At any one time, there may be multiple job numbers linked to the same
Product but with different Packing requirements. This is why I need to
record the selections to a new table. The packing records would be
deleted upon shipment in the system.

I have tried using an Apend query in a loop etc....i'm just confused on
how to get the selected records into the other table correctly.
David.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.