473,765 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to parse data from different tables to creat an auto generated number

zimes
4 New Member
I am working with Microsoft Access 2003 from the Office XP pro suite. I have created several tables that have to do with Asset tracking along with purchasing. I have a table called Purchasing, Assets, Comapnay, AssetCategorty, and AssetNumber. The number I would like to create would take data from Purchasing and Assets, then create a number that would be in this format:

YY| company 3 letter abrivation | Asset Type | 3 digit auto generated number
it should look like this
04ABCLTP001 or 04-ABC-LPT-001

For each table I have (unrealated data I have kept out):

Purchasing
PurchaseID {PK}
CompayPurchased For{FK to company}
DateRecieved

Assets
AssetID{PK}
AssetCategoryID {FK to AssetCategory}
AssetNum

AssetCategory
AssetCatID{PK}
AssetName

Company
CompanyID{PK}
Company
CompanyAbrv

AssetNumber
AssetNumberID{P K}
PurchasingID{FK to CompayPurchased For(The FK in Puchasing) and DateRecieved}
AssetID {FK to AssetCategoryID (FK to AssetCategory)}

The data parsed to PurchasingID into the AssetNumber Table needs to have the DateRecieved and CompanyPurchase dFor.
The data that goes to the AssetID in the AssetNumber Table comes from the AssetCategoryID in the Assets Table.

I then need to get that information to the AssetINum column in the Assets table and add the auto number.

the trouble is getting the finish product. the purchasingID in the AssetNumber is not showing the CompanyPurasded For information, just the date. I know I am missing something in the code since it is just comming in as the date and I dont know how to code it to show the last two digits in the year. I also want to show the CompanyAbrv instead of the full company name. here is the code:

SELECT PurchaseID, CompanyPurchase dFor, DatePurchased
FROM Purchasing
ORDER BY Purchasing.Date Purchased, Purchasing.Comp anyPurchasedFor ;

Q1) what am I missing in the above code to get the format of (YY/XXX)?

Q2) how would I code that information to point back to the AssetNum back in the Assets Table?


Tanks for the help in Advance
Apr 11 '08 #1
9 2262
nico5038
3,080 Recognized Expert Specialist
For your needs you need to look into the Format() function to get just the "YY" format, but I would like to warn you for generating these type of codes.
Just imagine what happens when adding a combination of "YY| company 3 letter abrivation | Asset Type" and it's already occurring 999 times....
Or what to do when a company's abbreviation changes...

Best way is always to use a "hidden" auto-number and show the actual data in forms/reports, so simply: Purchase Year, Company Abbreviation and Asset Type, optionally with an added sequence-number or (assuming there's a max of one order a day) the purchase date.

When you still want a sequence-number to generate, lookup the Dcount() function and use that for counting the number of times the combination exists.

Nic;o)
Apr 12 '08 #2
FishVal
2,653 Recognized Expert Specialist
....
When you still want a sequence-number to generate, lookup the Dcount() function and use that for counting the number of times the combination exists.
....
Hi, Nico.

That should be DMax() function anyway. ))

Regards,
Fish
Apr 13 '08 #3
nico5038
3,080 Recognized Expert Specialist
Hi, Nico.

That should be DMax() function anyway. ))

Regards,
Fish
Hi Fish,

Both will work having a "closed set" of sequence numbers.
When gaps are possible, then indeed the Dmax is better in getting a new unique number, but the Dcount() will be the way to go when initializing the sequence for an established set of records, as Dmax will set all to the same value :-)

Nic;o)
Apr 13 '08 #4
missinglinq
3,532 Recognized Expert Specialist
The problem is that gaps are all to often going to be there, and DCount() will result in duplicate values in that case. Use DMax(), as Fish suggested, and that's never a problem!

Linq ;0)>
Apr 13 '08 #5
zimes
4 New Member
For your needs you need to look into the Format() function to get just the "YY" format, but I would like to warn you for generating these type of codes.
Just imagine what happens when adding a combination of "YY| company 3 letter abrivation | Asset Type" and it's already occurring 999 times....
Or what to do when a company's abbreviation changes...

Best way is always to use a "hidden" auto-number and show the actual data in forms/reports, so simply: Purchase Year, Company Abbreviation and Asset Type, optionally with an added sequence-number or (assuming there's a max of one order a day) the purchase date.

When you still want a sequence-number to generate, lookup the Dcount() function and use that for counting the number of times the combination exists.

Nic;o)
From what I understand is not to put in a column in the Assets table for the custom number and just have it populate the number in the forms / reports. Is that correct? If that be the case could I just then use the PK for the number then format it how needed?

As far as the triple digit at the end, I plan on resetting the number back to 001 per year. 09abcdtp001, 10abcdtp001, etc. .

Thanks for the help guys. I will look the commands up.
Apr 14 '08 #6
nico5038
3,080 Recognized Expert Specialist
From what I understand is not to put in a column in the Assets table for the custom number and just have it populate the number in the forms / reports. Is that correct? If that be the case could I just then use the PK for the number then format it how needed?

As far as the triple digit at the end, I plan on resetting the number back to 001 per year. 09abcdtp001, 10abcdtp001, etc. .

Thanks for the help guys. I will look the commands up.
Hi zimes,

Best would be not to use a custom (sequence) number, as a change of a companies abbreviation will causes trouble in the assigned codes.
In general for a normalized table we use a unique (or set of) field(s) to identify the occurrence needed. In your case e.g. the Companyname (or when "fixed" the Abbreviation) and a Date (sometimes when multiple rows per date can exist the time is added). In that case the unique ID is easy to understand for the user(s) and no trouble with renumbering or "gaps" in the code will exist.

For grouping (report) data per year (Your YY part) you can use the Year() function on the datefield.
When you still want to use a Year and custom sequence number you could check:
http://www.geocities.com/nico5038/xC...Insert2000.zip
Personally I used that code for generating a year bound orderID.

Nic;o)
Apr 14 '08 #7
zimes
4 New Member
Thanks Nico. I am getting some great ideas for codding this.
Apr 17 '08 #8
zimes
4 New Member
Update:
after taking a look at my tables I had to delete the AssetNumber Table and ended up moving all columns that were needed for the Auto number into my Assets Table. I started messing with VB but could not wrap my head around the Syntax of the language (which Im not very good at ANY syntax by the way). I have dug up an old SQL codding book and was able to find the Format funciton but now the statement returns an error of: "The query cannot be used as a row source." here is the code:
SELECT Assets.*, format(DateReci eved, 'yy') as AssetDate, AssetDate & CompanyID & AssetCategoryID & AssetID AS AssetNumberID
INTO Assets
FROM Assets;

the only tables I am messing with now are Company, AssetCategory, and Assets.

I have also given up on the 3 digit format because it would require a complex piece of code that I would not be able to come up with.

What am I missing in my statement?
Apr 21 '08 #9
nico5038
3,080 Recognized Expert Specialist
Update:
after taking a look at my tables I had to delete the AssetNumber Table and ended up moving all columns that were needed for the Auto number into my Assets Table. I started messing with VB but could not wrap my head around the Syntax of the language (which Im not very good at ANY syntax by the way). I have dug up an old SQL codding book and was able to find the Format funciton but now the statement returns an error of: "The query cannot be used as a row source." here is the code:
SELECT Assets.*, format(DateReci eved, 'yy') as AssetDate, AssetDate & CompanyID & AssetCategoryID & AssetID AS AssetNumberID
INTO Assets
FROM Assets;

the only tables I am messing with now are Company, AssetCategory, and Assets.

I have also given up on the 3 digit format because it would require a complex piece of code that I would not be able to come up with.

What am I missing in my statement?
Sorry, have been very busy at work.
For creating a new table I normally create first a SELECT query to get the needed result. Next step is to change it into an Append query (see the Query menu for the options) targeting the final table (Access will ask for it when switching the querytype). Just one thing to keep in mind when you have an autonumber ID, you need to keep that out of the fields that are "moved" to the target table.

Nic;o)
Apr 29 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
4811
by: Redd | last post by:
The following is a technical report on a data modeling project that was recently assigned to me by my professor. I post it so that anyone else who is studying databases and data modeling can have an example to go by with their study of databases. I was assinged to come up with a data model, but I choose the Autoparts sales and inventory management schema. It you would like the SQL code to generate the schema or if you would like the ERWin...
2
2469
by: Greg Strong | last post by:
Hello All, I've written code in a test database with test data. Everything seems to be working except compact database in VB code per http://www.mvps.org/access/general/gen0041.htm. The reason I say this is the auto number fields are NOT being reset to zero. I delete the data from tables with action delete queries, then call the compact DB code which is followed by importing data to tables and subsequent append queries to other tables....
0
1561
by: Viorel | last post by:
Working as a beginner with data objects in Visual Studio 2003 and C#, I use the "Generate Dataset" command in order to generate automatically the dataset objects based on data adapters. Generated objects offer a convenient way of working with database fields. For instance, if a database table contains a "quantity" column, then, in the program, you will use expressions like "row.quantity". This is more comfortable then writing something as...
9
2834
by: Jenden0 | last post by:
I'm new to C# (and Microsoft in general) so this may be a simple problem, but I haven't been able to figure it out yet. I've got a database with a number of different tables and I want the user to be able to select which table they want, then have that table pop up in a datagridview. I've figured out how to get it to work if I specify the table adapter to use and do it all manually, but I'd like to make a method that will populate the...
34
2985
by: priyanka | last post by:
Hi, I was wondering if we could parse or do something in the executable( whose source language was C). How can I use some scripting language like perl/python to find out the information about the executable ? Is it possible ? Also, how does the compiler add inling to the program ? I know that whenever it sees"inline" in front of the procedure name, it inlines it. But if we give the -finline options, it inline all the procedures ? How
5
2985
by: BMeyer | last post by:
I have been losing my mind trying to parse an XML document (with nested child elements, not all of which appear in each parent node) into a DataGrid object. What I want to do is "flatten" the XML document into a text document with a single row for each parent node (that has all of the values from all of the child nodes for that row) The DataView within VS 2005 IDE displays my 15 or so child tables - and knows that some parent rows...
9
3137
by: sellcraig | last post by:
Microsoft access 2 tables table "data main" contains a field called "code" table "ddw1" is created from a make table query of "data main" Goal- the data in "code" field in needs to be inserted into a standard web address in the table (the filed name is link) in ddw1 Example address ---
10
2793
by: Sjaakie | last post by:
Hi, I'm, what it turns out to be, fooling around with 3-tier design. At several websites people get really enthusiastic about using custom dataobjects instead of datasets/-tables. While trying to write such layers myself I got stuck on how to get filtered or sorted data from the data-layer. This is what I got: Objects
14
1805
by: jmDesktop | last post by:
I have a food menu. Each area, like beverages, grill, etc. have items under them, Coke, Tea, Coffee would be under beverages for example. I want to add a new drink to beverages. In my database I have an "area" like above, Bevs, Grill, Chicken... In my menu items I have an ID from the area so, table areas id 1 areaname beverages id 2 areaname grill
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9404
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10164
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3926
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.