473,320 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Using part of a field to fill in another field?

I am making an inventory database. I have a field InventoryNumber
where I put a specific code. The code always starts with a particular
letter. I would like to fill in another field with specific
information based on what that letter is. Can somebody show me how to
do this? Thanks in advance.

Nov 13 '05 #1
3 1811
Hmmm...there are a lot of ways that you can do this. It depends on how
many possibilities you have for that first letter.

If there are lots of possibilities OR if you expect the list to grow,
you could create a table that holds the list of your 'specific
information' and a letter ID that corresponds to the 1st letter in your
InventoryNumber field. I am assuming that each letter corresponds to a
unique value for the desired information, such as A = Apples, B =
Bananas, etc. and that you don't also have A = Apricots. If that's a
valid assumption, create a table with two fields in it: AlphaID
(primary key, 1 character long) and Description (text). Enter in all
your items into the table. Since this would be a table with a maximum
of 26 entries, you could then use a
DLookup("Description","tblDescriptions","AlphaID = '" &
Left(InventoryNumber,1) & "'" in a form or a query to grab the
description that belongs to the 1st letter of your InventoryNumber.

If there are only a few possibilities AND you DON'T expect the list to
be changing, you can create a custom function using the Select Case
statement in VB. It would be something like this:

Public Function GetDescription(InventoryNumber As String) As String
Select Case Left(InventoryNumber, 1)
Case "A"
GetDescription = "Apples"
Case "B"
GetDescription = "Bananas"
Case "C"
GetDescription = "Cantaloupe"
Case Else
GetDescription = "Invalid Letter in Inventory Number"
End Select
End Function

You could then use that function anywhere you'd like to get a
description.

HTH,
Jana

Nov 13 '05 #2
I decided to do it like this and it works great. Thanks for the help.

Private Sub InventoryNumber_AfterUpdate()
If InventoryNumber Like "d*" Then
FolderName = "D Items"
Folder_Code = "640079"
End If
If InventoryNumber Like "j*" Then
FolderName = "J Items"
Folder_Code = "640061"
End If
If InventoryNumber Like "g*" Then
FolderName = "G Items"
Folder_Code = "640372"
End If
If InventoryNumber Like "M*" Then
FolderName = "M Items"
Folder_Code = "640060"
End If
End Sub

Nov 13 '05 #3
Just out of curiosity, what do you do when it doesn't start with D, J,
G or M?

Dec 7 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: NohaKhalifa | last post by:
Dear All; I'm developing a web site and i need to make adminisration for this site it's a site for Real Estates . But I don't need the administration to be online .. I want them to fill data...
10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
10
by: DettCom | last post by:
Hello, I would like to be able to display or hide fields based on whether a specific Yes/No radio button is selected. This is in conjunction with a posting a just made here in the same group...
8
by: doomx | last post by:
I'm using SQL scripts to create and alter tables in my DB I want to know if it's possible to fill the description(like in the Create table UI) using these scripts. EX: CREATE TABLE(...
0
by: Ross Dempster | last post by:
Hi everyone, this is quite involved but if anyone can help (or just likes a challenge!) i would very much appreciate it. Quick intro : I have forms based authentication (though i do it manually...
4
by: jay | last post by:
I am using the dataset object to add a row to a sql server database in vb.net code, as follows: dim drow as DataRow dim cmdBld as new SqlCommandBuilder(mySqlDataAdapter) ds.tables(0).NewRow()...
0
by: koonda | last post by:
Hi guys, I posted a message before and I got some help from the forum. I have a database in SQL Server and I wanted to create a web interface in C#. I had 4 Listbox controls and a Textbox and two...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
106
by: bonneylake | last post by:
Hey Everyone, Well i don't know if my question should be in javascript/ajax or coldfusion, i figure this is more of a coldfusion question. But if this is in the wrong section let me know an all...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
0
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...
1
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)...
0
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...
0
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....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.