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 2412
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: 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
|
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...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |