473,671 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to ask Access to find last serial number for a certain category?

1 New Member
I have a database that is for keeping track of inventory. I need to have my form for entering new inventory to automatically make a new serial number based on the category of the new item.

The serial numbers are currnently like this:
AA######

"AA" = Category code
"######" = the next number

I currently have a category combobox and an item combobox and the serial number txt field. The options in the item combobox change based on the category selected. i currently have the serial number generating fine but the problem is that it generates the next number over all not for each specific category. for example, if there are three items; BO000001, CA000001 and CA000002, and i want to ad another item under the BO category, currently the serial number that pops up will be BO000003 because it is taking the number from "CA000002". i want it to only look at the BO's and make the serial BO000002.

Not sure if i explained this very well but here is the code i have now:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub cboCategory_AfterUpdate()
  4. Me.cboItem = Null
  5. Me.cboItem.Requery
  6. Me.cboItem = Me.cboItem.ItemData(0)
  7. Me.txtSerialNo = Me.cboItem.Column(2) & Format(Val(Right(DLast("[Serial Number]", "Inventory"), 6)) + 1, "000000")
  8. End Sub
  9.  
  10. Private Sub Form_Current()
  11. Me.cboItem.Requery
  12. Me.txtSerialNo.Requery
  13. End Sub
  14.  
  15. Private Sub Form_Load()
  16. Me.cboCategory = Me.cboCategory.ItemData(0)
  17. Call cboCategory_AfterUpdate
  18. End Sub
  19.  
  20.  
Any and all help is appreciated!
Aug 28 '10 #1
1 2095
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
First note that the first line of help for DLast(AC2003) says:
You can use the DFirst and DLast functions to return a random record from a particular field in a table or query when you simply need any value from that field.
making it quite unsuitable for your needs.


Expand|Select|Wrap|Line Numbers
  1. Me.txtSerialNo = Me.cboItem.Column(2) & Format(Val(Right(dmax("(tx_Serial)","Inventory","left(tx_Serial,2)='AA'"),6)) + 1, "000000")
Assuming you have your category code somewhere in your form, lets presume cmb_Category you could write:
Expand|Select|Wrap|Line Numbers
  1. Me.txtSerialNo = Me.cboItem.Column(2) & Format(Val(Right(dmax("(tx_Serial)","Inventory","left(tx_Serial,2)='" & me.cmb_Category & "'"),6)) + 1, "000000")
Aug 30 '10 #2

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

Similar topics

21
43031
by: Gavin | last post by:
Hi, I'm a newbie to programming of any kind. I have posted this to other groups in a hope to get a response from anyone. Can any one tell me how to make my VB program read the Bios serial number (or would HDD be better, or both?) and put that info into VB prog so the program won't work on another computer. My program uses an MSAccess table. Much appreciated if you can help! Thanks
79
14065
by: Klaus Bonadt | last post by:
In order to protect software from being copied without licence, I would like to use something like a key, which fits only to the current system. The serial number of the CPU or the current operating system would be appropriate. However, I do not know how to retrieve the information. Could you help? Klaus
3
4125
by: misc | last post by:
Does anyone know how to access the Volume Serial Number of a drive using .NET? It is easily done in VB6 using the FilingSystemObject. I appreciate any insight into the matter.
1
1268
by: CLEAR-RCIC | last post by:
Where can I find the serial number that I need for installing Windows XP from MSDN?
3
5663
by: Mark Harris | last post by:
I have an installer which uses a Customer Information page in it, is there an easy way to pass the serial number entered to a custom action? If not, where would i find the serial number in the registry? I'm using C# for the custom action -- Mark Harris
15
583
by: tom | last post by:
Hi, How do I get the serial number of the harddisk in .NET? I want this to be the same number even if the user has reformatted, so I do not want the volume serial number. Thanx, t
10
1829
by: Marina | last post by:
Can anyone tell me if there is a way to auto number by category? I have 2 tables, ExpenseCategories and Vendors. Each there are many vendors to each expense category, but each category has a specific set of numbers for each vendor listed in it. i.e. Expence Catigory is Office Supplies... all vendors for that catigory are listed between 22401 and 22499. Is there a way to have it auto number so Office supplies would start at
3
4809
by: bayazee | last post by:
Hi, How can I get CPU Serial number , or motherboard serial number with C . I need an idetification of a computer .... ThanX --------------------------------------------------- iranian python community --www.python.ir
2
2273
by: buddyr | last post by:
Hello, I have a cmd button on form to search for serial number. I notice when I search for record-that if I don't start at the beginning of records I might not find the record. example: if I am searching for 20th record then I search for 10th record I will have to go to to beginning to search for 10th record. Any way to not have to go to the start each time? I have tried using code with find first in it- but it seems like find first is not...
0
4836
Airslash
by: Airslash | last post by:
Hello, I've written a class that resembles a hard drive. I'm already able using the Windows API to get information such as the remaining free bytes, the sectors and clusters,a nd it all works fine. The last step that I need is to obtain the serial number of the harddrive in question. From what I can understand in the MSDN library you need to take into account that a Volume can span multiple disks etc, but I don't wanne waste time on that...
0
8472
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
8390
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,...
1
8596
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
8667
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7428
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5690
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
4221
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2806
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
1801
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.