Modules & VBA :: Auto Increment Field Based On TWO Other Fields

Jun 5, 2013

I'm making up a stock system for the independent jewellers I work for. Each stock pattern needs an individual code which can quickly be recognised read as tickets are often taken off the jewellery and can be mixed up easily. To this end we categorise based on two criteria:

1. Material
2. Type

At the moment these are as follows:

MATERIAL

IDMaterial
0Base and Miscellaneous
1Silver
2Gold
3Palladium
4Platinum
5Pewter

TYPE

IDStock Type
0Previously Owned
1Ring
2Pendant
3Chain
4Necklace
5Bracelet or Bangle
6Earrings
7Brooch
8Gents
9Gift, Clock or Miscellaneous

So if I had three pairs of silver earrings I want the first to be No. 161, the next 162, the next 163. If I had three Gold Bracelets I'd want them No. 251, 252, 253 and so on...Material and type are both selected form separate Comboboxes on a form.

View Replies


ADVERTISEMENT

Auto Increment Field Based On Value Between Two Numbers

Apr 25, 2013

I have inherited an Access DB that is supposed to be kept "alive" but not made much better. On a weekly basis I get an Excel CSV that I'm supposed to import into one massive table; that works just fine.

However, there is another query that takes values from a table named "New Users From Import Table" and appends them to the current "User" table.

But before running that query I have to manually update a field called "Display Name ID" with the next highest number from the User table but only the highest value that isn't in the 9000 number range.

For example, my next highest "Display Name ID" is 1144, which of course does not include the records that range between 9000 - 9008.

I had to manually enter 89 "Display Name ID" values yesterday and I know there has to be a way to update that field when I pull the data over from the temp table without having to do it all manually.

Here's the query that pulls the data into the "User" table (after I've manually entered the incremented values).

INSERT INTO Users ( [Display Name ID], [User Type], Organization, [Display Name], [Alias Name] )
SELECT [New Users From Import Table].[Display Name ID], [New Users From Import Table].[User Type], [New Users From Import Table].Organization, [New Users From Import Table].[Display Name], [New Users From Import Table].[Alias Name]
FROM [New Users From Import Table];

View 13 Replies View Related

Auto Increment Numbers Based On Value In A Different Field

Feb 22, 2012

how to auto increment one field based on the value in another field. What I have is a table with six fields. There is a foreign key assigned to each record and linked to another table. Four fields in this table are number fields indicating accordingly a number for a category, a number for a subcategory, a number for a subject for a subcategory and a number for an instruction for each subject of subcategory. The last field is the text field for each instruction. Numbers are required to be included in the report. Also, number of categories, subcategories, subjects and instructions vary by each record in the the table which this table is linked to. What I'm trying to accomplish is to have numbers in the subcategory to auto increment starting with "1" for each number in the category field, numbers for each subject field would auto increment starting with "1" for each number in the subcategory field, and numbers in the instructions field to auto increment for each number in the subject field starting, again, with "1". I also need these numbers to restart with "1" for each new record in another table.

Basically, the table would look like this:

cat subcat subj instruction
1------1-------1------1
1------1-------2------1
1------2-------1------1
2------1-------1------1
2------1-------2------1

3------1-------1------1
3------1-------2------1
1------1-------1------1

(if the record in another table is a new/next table)and so forth..I have been looking for anything that could remotely work for me. Every VBA code I've tried is either don't work the way I need it to work, other codes making the field to continue increment numbers if the number already exists in the other field.

View 1 Replies View Related

Auto Data In One Field Based On Other Fields?

Feb 27, 2008

Hi,

I have a table that is used for project progress. One of the fields is named "Completed". I would like to know if it's possible to auto fill the data in the "completed" field based on three other fields within the same table.

ex: If field 1 = Yes, and field 2 = Yes, and filed 3 = Yes, then field "completed" = Yes

I'm open for any ideas, I'm new to access and am not sure how to get this started.

Thanks

View 3 Replies View Related

Auto-filling Fields Based On Another Field

Dec 7, 2004

hi all...

i am the biggest of all newbies when it comes to access and understand only the graphical parts of the process (no SQL knowledge etc.).

how would i go about auto filling a certain field based on what's in another field? for example, i have a field called TimeZone that i want filled with either West, East, Central, or Mountain based on another field for State. can i build a query to automatically take care of any empty fields for TimeZone that haven't already been filled out by me manually?

if i need to use SQL, that's fine too as long as the directions are clear and precise as i have no prior knowledge.

thanks a bunch.

View 4 Replies View Related

Field In Table Auto Increment

Feb 12, 2008

I have a table with order numbers I would like to auto increment the number part of the order when new record is added to the table.

My order numbers looks like this:

UZSK-0001
UZSK-0002
UZSK-0003
UZSK-0002

How to make access increment the number part?

View 14 Replies View Related

Auto Increment Field In A Sub Form

Aug 7, 2006

Basically, we have different camera modules on which we perform a given test a number of times, giving rise to 2 tables, tblCamera which will store basic info about the module and tblTest which will hold info for each test perfomed.

The camera module has a unique ID (CameraID, the Primary key in tblCamera and foreign key in tblTest (one to many)). The primary key in tblTest will be a compound key of CameraID and an incremental number for each test performed on a given camera (TestNo). The data for the tests will need to be entered through a form, so I can build a form based on tblCamera with a subform based on tblTest (which would be in datasheet view)... What I am looking for is a way to increment TestNo in the subform, starting at 1. I have tried using

=Nz(DMax("TestNo","tblTest","CameraID = '" & [Forms]![frmCamera]![txtCameraID] & "'"),0) + 1

in the Default Value box for this field, which works to a point but has the curious effect of adding each number twice (as the default value for a new record seems to be added as soon as you start typing in the current 'last row')

I just can't seem to get my head around this one, any suggestions would be much appreciated...

Thanks,
Bogzla

View 2 Replies View Related

Queries :: Alter Table With Auto-increment Field?

Mar 10, 2015

I am attempting to update an oracle table using MS Access.

One of the fields to be updated is a primary key number field.

I'd like to use the autoincrement field to update that field.

My sql is:

Code:

Alter table testAutoNum Add column progid autoincrement (1001,2)

This sql nicely creates the new field in the table, but it doesn't start at 1001 and increment by 2; it starts and 1 and increments by 1.It is also creating an autonumber and I need it to be a number.

What am I doing wrong?

View 7 Replies View Related

How Can I Configure A Table To Auto Data Entry Into Fields Based On A Previous Field

Aug 31, 2006

My situation is this. I have 3 tables that I have imported from my mainframe system, between these 3 tables I have the data of product code, description,supplier code, supplier name, order method, and ABC code.

I am trying to create another table that I can capture daily Out Of Stock data for products.

What I would like to do is to enter the product number in the first field of my new table, and then the remaining fields will auto populate with the correct details based on the product data stored in the parent tables that I have imported.

How can this be done?

View 3 Replies View Related

Auto Increment A Number Based On Record Value From Previous Record

Nov 17, 2010

create a macro that automatically fills in the next invoice number in sequence",,I'm assuming this macro would look at the value of the previous record and add a one to itI don't want to use a AutoNumber field as I might need

(a) to modify value or
(b) need to skip numbers.

View 8 Replies View Related

Beginners Question - Auto Update Fields Based On Fields In Another Table

Nov 26, 2007

I don't have any database experience whatsoever so please go easy.
I'm guessing this kind of this is extremely simple for all of you.

I'm constructing a database of network resources and devices and I'd like to automatically update the values in one field based on the values of a field in another table.

The first table is called "IP" and the fields are called "Address", "IP Type" and "Device".
The second table is called "Devices" and contains the fields "Name", "Description", "Asset Number" and "IP".

Here's an example of the tables: (ignore the "code" tag. i've only used it to align my columns properly)

DEVICES:
NameDescriptionAssetIP
XserveFile Server107203.30.144.75
ProliantXDHCP119203.30.144.15



IP:
AddressIP TypeDevice
203.30.144.75Static
203.30.144.15Static


What I want is for the Device field in the IP table to automatically update it's values based on the values found in the Devices table. In this case, the values that should appear in the Device field in the IP table are "Xserve" and "ProliantX".

I've searched through but haven't found a complete solution, just little pieces which I'm too inexperienced to put together myself.

thank you
-Tim

View 2 Replies View Related

Auto Rearrange Fields Or Hide Fields In DataSheet Based On Criteria

May 17, 2007

I have main form and that has one sub-form , this Main form governs/determines the data in the sub form.

This Sub form ( DataSheet Mode) has approximately 130 columns and based on the Main form criteria only ~ 20 columns has to be filled.

What I want to do is based on the main forms criteria I want to show only the columns that are applicable to main form criteria.

If I use Columnar or Tabular single form for the Sub Form I am able to hide the fields that are not required BUT IT LEAVES A SPACE/GAP on form ( for the hidden fields that are not required)

Private Sub Form_Load()
If Forms!frmShowPIforActiveAndCanAddNewPI!FrmSubFrmFi lterProductInformationPerFMT!CASETIF = True Then

Me.CASETIF.Visible = True
Else
Me.CASETIF.Visible = False
End If
End Sub


And If I use DataSheet and hide ( visible = no) a particular filed it still shows up in Sub Form

Is there a way to Auto-Re Arrange all the fields in the sub form so that the hidden ( visible = no) fields no not leave gap


Or is there a way by VBA program to select fields ( Columns) from a table to be displayed on a sub form based on a criteria

Thanks
Rahul

View 1 Replies View Related

Modules & VBA :: Lock Certain Fields On Form Based On Value In A Particular Field

Aug 4, 2015

I'm trying to lock certain fields on my form based on the value in a particular field. It seems to work the first time but applies itself to all other records in the database from then on!

The starting point is a command button that sends an email and makes Me.DPLLock = 1. The corresponding table entry is formatted as a number.

The code is...

Private Sub Form_Current()
If Me.DPLLock = 1 Then
Me.OR_Name.Locked = True
Me.OR_Sales_Order.Locked = True
Me.OR_WO_No.Locked = True
Me.OR_Qty.Locked = True

[Code] ....

Ive tried Me!DPLLock with the same result.

View 7 Replies View Related

Modules & VBA :: How To Increment Field On A Continuous Form

Mar 31, 2014

I have a form that is being used for sample submission. Ideally, the user will be able to put in some information (3 or 4 fields) and the number of samples that they're taking, click the arrow and it will insert that number of samples into a temporary table that is then displayed on a continuous form. From there, they can edit samples, add more samples, and generate a report to submit to the genotyping group. Once their sample list is final, I will append it to the master list and clear the temporary table.

I've got the basics working. A looped "INSERT INTO" using a counter inserts the relevant information. I cannot, however, seem to get the numbering field to work.

Ultimately, the numbers need to look something like MySample-001, where MySample would be one of the other fields. Incrementing the 001 is the problem. In another situation in the database, I can successfully use DMax+1 to assign a single number on a single form, but I can't get it to increment the sample numbers.

Ideally, I'd like it to happen when the form is generated. However, I'm also open to having them assigned when the sample list is finalized, before inserting into master table.

View 8 Replies View Related

Modules & VBA :: Splitting Dataset Sorted On Two Fields Based On Change In Value In One Field

Feb 6, 2014

I am new to MS Access, and am not sure if what I want to do is even possible. It is my understanding that comparing subsequent cells within a field in a database cannot be done- so I thought I'd see if there is a way to go around it.

I have a dataset for pedestrian activity, with over 3 million rows and 40 columns - too big for excel to handle.

I need to sort the entire dataset by 2 fields, following which I need to search down the field containing my pedestrian ids (numbered 1, 2, 3... till approx 10000), and when my ped id changes from one to the next, I need to check the value in a field showing the ped location, and if that matches with the ped's previous location, I need to copy out a cell corresponding to the previous cell's time stamp. If it doesn't match, I need to copy out another time stamp from another field.

View 1 Replies View Related

Modules & VBA :: Increment Variable Length Alpha Numeric Field By 1

Jul 8, 2013

I have a database that is used for tracking changes to numerous courses. Part of this database create a unique tracking number for each course problem developed. Currently I have the form do a comparison using the highest most number to compare against the current number assigned and prevent the form from saving until the number is incremented and not a duplicate, it would be a lot easier if I could just have it increment plus 1. I have seen various answers but they all seem to depend on the alpha portion of the field being a set value, in my instance it is variable in length. The only part that is fixed is the last four characters to the right which are the numeric portion I would like to increment. For example the field can equal:

QACP-M-PIQ-6059
QACP-M-PREF-6002

how to extract just the numeric portion, increment it by one and save?

View 2 Replies View Related

Auto Increment Value

Mar 23, 2008

Hi All

How to assign value to a field based on the value of the same field in the previous record?
Autonumber has its limitations for my purpose. Because, after I start filling up a form, I some times cancel the form filling process, and it affects the continuous numbering.

I guess the issue can be resolved by using some thing like record count facility. i.e. current' record's field value = number of records till previous record + 1.

How to exactly codify or execute the above by vba coding.

The Field Name is "SerialNo.", and Table Name is "StudentData"


Thanks

Padhuka

View 5 Replies View Related

Auto Increment

Jan 29, 2008

I am importing an Excel file with existing data using the Import wizard to build my table. It has an ID field (CID) which I would like to keep and set to auto increment starting with the next number.
Can this be done ?

View 2 Replies View Related

Modify Auto ID Increment

Aug 22, 2007

Hello,

Can someone tell me how I can change the increment in an existing database.

The PK is currently Auto ID with each new record currently 1001, 1002 and so on.

What I am trying to do is say starting monday the next new entry begins at 5003 versus 1003, in essence I am trying to change my first number to a 5 versus a 1.

Is this possible?

Thanks..
Fen How

View 8 Replies View Related

Auto-increment Values

Dec 26, 2006

hello

I have set up the primary key as auto-increment through sql.
coursereference int AUTO_INCREMENT,
I have also entered VBA code for event handler below:

Private Sub Form_AfterInsert()
Me.Requery
DoCmd.GoToRecord , , acLast
End Sub

Every time when I delete the previous value , the next one entered is not decreased by one.
Could you please help how to set it up?

Thanks

View 3 Replies View Related

Resetting Auto Count/Increment

Jul 3, 2007

I'm redeveloping a DB for a new project, so have removed all previous records from relevant tables (to start a-fresh)

One snub, the ID fields in the tables are auto increasing from where they left off, rather than from 1

If anyone knows how to reset the auto counters, it would be very much appreciated

Thanks in advance

View 4 Replies View Related

Primary Key-Auto Number - Increment

Feb 12, 2008

Hello ALL,

I want to know how to reset (to start again from 1) my primary key field. As an example i have the "Customers" table with the field "customerID" as PK now i entered many values (20) then i deleted them but i want to start again and the "customerID" value starts with 21 i understand that but i want a fresh DB (i was testing things) and i want to start from 1 can i? how? i even deleted the relation between this table and the other table but no success!

Some help please?

THX in advance

View 4 Replies View Related

Create Auto-increment In The Query

Sep 15, 2005

Hi: does anybody knows how to create auto-increment in the query?
eg.
id
1
2
3
4
...
create auto-increment in the query, Not in the table? Thanks.

View 2 Replies View Related

Primary Key-Auto Number - Increment

Feb 13, 2008

Hello ALL,

I want to know how to reset (to start again from 1) my primary key field. As an example i have the "Customers" table with the field "customerID" as PK now i entered many values (20) then i deleted them but i want to start again and the "customerID" value starts with 21 i understand that but i want a fresh DB (i was testing things) and i want to start from 1 can i? how? i even deleted the relation between this table and the other table but no success!

Some help please?

THX in advance

View 2 Replies View Related

Auto Populate Fields Based On Combo Box Selection

Jan 23, 2013

I have three tables with the following columns:

MoldReq
Mold_NoPart_NamePart_NoMaterialDateWork_Ord(Pri Key)
MoldLog
Log_IDMold_No(Pri Key)Part_NameLog_DateTime_InTime_OutHours
Molds
Mold_No(Pri Key)Part_NamePart_No

I am trying to build a form in the MoldReq section so when the user selects the mold number(combo box) it will auto populate the Part_Name and Part_No fields by pulling the data from the Molds table.

I have tried following this video where I create a change event:

Code:
Private Sub cboCombo31_Change()
Me.txtPart_Name.Value = Me.cboMold_No.Column(3)
Me.txtPart_No.Value = Me.cboMold_No.Column(4)
End Sub

View 14 Replies View Related

Adding A Auto Increment Text/Number

Jan 4, 2005

I have a daabase that I am importing via excel. I want the entries to be numbered
ex: MT0001
MT0002
etc....

I would like it to promt the user for the last number(or next number in sequence) entered, then fill in the blank records with the next increment number.
The prefix will also change to so eventually the user would enter into the prompt RD0001. then autofill the 140 imported records with RD0002, rd0003... etc....

I can't really make seperate fields because the MT0001 number will become a barcode and putting them seperate causes many issues.

can this be done? Any help would be great I am still a beginner but slowly learning!
Thanks!

View 13 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved