Hi
I am sure there is an easy way to do this but I have exhausted all avenues.
I have some label data in a table which I want to copy to an identical table. However the first label I may only want one of that label data copying to the new table. The second label I may want seven of that label data copying to the new table. I have a count field called "nooflabels"! which has 1 in the first record and 7 in the second.
I have created an append query and set up a macro to run then created a button in my form to run that macro -
Dim thecount As Integer
-
Dim stDocName As String
-
thecount = Me.Nooflabels
-
-
-
stDocName = "Create_duplicatedespatches"
-
DoCmd.RunMacro stDocName, thecount
-
Problem is that the query doesnt treat each record separately so I either end up with 1 of each record or 7 of each record.
How can I split this out.
Am feel I am going down the wrong track and wondering if I should be using loop although i have never used this before.
Please could someone advice on this.
Thanks
jacc14
10 2408
Hi, jacc14.
It is normally done in VBA via recordset iteration. I'm sure you will receive numerous advices of how it could be done.
So I would suggest you pure SQL solution. Just to show feasibility of this approach. See attachment.
Regards,
Fish
Dear FishVal
This is excellent. I have applied and it works a treat.
Thank you
Jacc14
Dear FishVal
I hope you dont mind me directing this question to yourself but you already know where I am going with this and I am struggling again
The table which I have now produced looks like this. - ID Label Value Count Unique Number
-
1 Label1 50 7 1
-
1 Label1 50 7 2
-
1 Label1 50 7 3
-
1 Label1 50 7 4
-
1 Label1 50 7 5
-
1 Label1 50 7 6
-
1 Label1 50 7 7
-
2 Label2 100 1 1
I now need to assign a unique number by each group of records. This is so that when I print the labels it will say 1 of 7, 2 of 7, 3 of 7, 4 of 7, 5 of 7, 6 of 7, 7 of 7 and then for label2 it will say 1 of 1. This means that each batch of labels will have there own group of numbers. See above under Unique Number.
I have used DMAX in a form before and know that this is the answer but I really want to put it in the sql query that you have helped me with as this is the part that creates the duplicated records. Is this possible. Sorry to be a pain.
Many thanks
Jacc14
sorry FishVal. Table doesnt look so clear now I have submitted it. Hope it makes sense.
Best regards
Jacc14
Hello, jacc14.
Below is a query (in context of the attachment tables): -
SELECT tblItems.keyID, tblItems.txtText, tblMultipliers.lngMultiplier & ' of ' & tblItems.lngQuantity AS txtCopyNumber
-
FROM tblItems INNER JOIN tblMultipliers ON tblItems.lngQuantity >= tblMultipliers.lngMultiplier;
-
Regards,
Fish
NeoPa 32,556
Expert Mod 16PB
I may be way off base here Fish, but shouldn't that be something more like (I'm working with no meta-data) : - ...
-
FROM tblItems INNER JOIN tblMultipliers
-
ON tblItems.keyID = tblMultipliers.[SomeIDField]
Ok. I would like to clarify the basics od the proposed solution. - [tblMultipliers] is an auxiliary table storing sequential natural numbers {1,2,3,4 ... N}.
metadata: -
Field Type
-
[lngMultiplier] Number(Long)
-
- Table join is used to combine records from [tblMultipliers] where [lngMultip[lier] <= [ ... tblItems field storing required number of copies ... ] with a record from [tblItems].
-
SELECT tblItems.keyID, tblItems.txtText, tblMultipliers.lngMultiplier & ' of ' & tblItems.lngQuantity AS txtCopyNumber
-
FROM tblItems INNER JOIN tblMultipliers ON tblItems.lngQuantity >= tblMultipliers.lngMultiplier;
-
Regards,
Fish
Dear FishVal
I have applied the code and its spot on. Thanks for your help. Much appreciated.
Best regards
Jacc14
You are welcome.
Best regards,
Fish
NeoPa 32,556
Expert Mod 16PB
...
[tblMultipliers] is an auxiliary table storing sequential natural numbers {1,2,3,4 ... N}.
metadata: - Field Type
-
[lngMultiplier] Number(Long)
...
Ah, that makes more sense now.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jason |
last post by:
In enterprise manager I am copying a table from one database to
another. I am using the dts wizard to import the data. After I
successfully import the data, I open both tables to compare the...
|
by: DP |
last post by:
I read some articles and post how to optimize te speed of asp pages
regarding opening and closing DB connections but I am still not sure
about this.
Is it true that it doesn't matter how many...
|
by: donal.conlon |
last post by:
I'm using a few threads to run a commandline tool and read the outputs.
What I want to do is run the tool several times with different
arguments every time. i.e.run the process in its own thread,...
|
by: Rahul |
last post by:
Earlier this evening i posted a question that my debug point is hit
several times, But after I published the application. I could
significantly see less round trip per request for Application_Begin...
|
by: pedro8ae |
last post by:
I have a table with multiple records and one field that determine
wheter or not the record is in use (Yes/No). I create a Query to list
all the Yes in that table BUT, when I list or run my query...
|
by: francisantony |
last post by:
Hi,
In my ASP.NET2.0 application, the Session is restarting several times in the same instance of the browser. I have specified the Mode = InProc of the 'session state' tag in the web.config.
...
|
by: lezilgeorge |
last post by:
I wanted to run an undate query in a for loop several times.....But When i run this only the 1 st row is getting updated and shows an error which says String or binary number is truncated, i am using...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
| |