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: -
Option Compare Database
-
-
Private Sub cboCategory_AfterUpdate()
-
Me.cboItem = Null
-
Me.cboItem.Requery
-
Me.cboItem = Me.cboItem.ItemData(0)
-
Me.txtSerialNo = Me.cboItem.Column(2) & Format(Val(Right(DLast("[Serial Number]", "Inventory"), 6)) + 1, "000000")
-
End Sub
-
-
Private Sub Form_Current()
-
Me.cboItem.Requery
-
Me.txtSerialNo.Requery
-
End Sub
-
-
Private Sub Form_Load()
-
Me.cboCategory = Me.cboCategory.ItemData(0)
-
Call cboCategory_AfterUpdate
-
End Sub
-
-
Any and all help is appreciated!
1 2095
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. - 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: - Me.txtSerialNo = Me.cboItem.Column(2) & Format(Val(Right(dmax("(tx_Serial)","Inventory","left(tx_Serial,2)='" & me.cmb_Category & "'"),6)) + 1, "000000")
Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
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
|
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.
|
by: CLEAR-RCIC |
last post by:
Where can I find the serial number that I need for installing Windows XP from
MSDN?
|
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
| |
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
|
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
|
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
|
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...
|
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...
|
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...
| |
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,...
|
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,...
|
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...
|
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...
|
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();...
|
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...
| |
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
|
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...
| |