Forms :: DMax Criteria - Generating Sequential Number

Oct 11, 2013

I'm using the following code to generate a sequential number"

Code:
Private Sub Form_Load()
Me.txtReceivedDate = Now()
'assign an EmailID when form loads
Dim CurMax As Long
Dim NewMax As Long
'poll the current EmailIDs for the largest number from current year and add 1

[Code] ....

Until recently, I didn't have any criteria on the DMax and it worked perfectly. It's now been decided that the EmailID should reset back to 1 when the calendar year changes.*

*EmailID is not my primary key - There is a separate autonumber field used as the primary key.

The table I'm using the DMax on has a field named ReceivedDate which stores a Now() when a record is created. The form I'm working in has a textbox named txtReceivedDate that is set to Now() when the form loads as can be seen in the code above.

What I'm trying to use as my criteria in the DMax is to match the Year() of ReceivedDate in tblEmails to the Year() of txtReceivedDate on the form.

For 2013, the current max (CurMax) EmailID is 21. If I set my computers date back to 2012 (where the CurMax is 3) the txtEmailID is still being populated with 22, even though txtReceivedDate shows a 2012 date.

I've tried a handful of permutations of the criteria string:

Code:
Year([ReceivedDate]) & " = " & Year(Forms!frmNewEmail!txtReceivedDate)
Year([ReceivedDate]) & "=" & Year(Forms!frmNewEmail!txtReceivedDate)
Year([ReceivedDate]) = Year(Forms!frmNewEmail!txtReceivedDate)

I've tried a few others long the way that I don't even remember, but there's probably little value in listing all the ways that don't work.

I've got a syntax issue within the criteria since it's the first time I've tried to use one and it contains a couple moving parts.

Once I get this sorted out a follow on question is about dealing with the users changing the txtReceivedDate to a different year. As of now, I have the same code (everything except "Me.txtReceivedDate = Now()") also present in txtReceivedDate_LostFocus(), but I'm not sure that's the best place for it.

View Replies


ADVERTISEMENT

DMax() For Sequential Autonumber

Jul 23, 2005

Hello Access friends,
Trying to have a sequential autonumber for the ScreenID with the DMax () function.
Please advise on what is wrong with the following :
=Nz(DMax("[ScreenID]","[Screenprep]","[ScreenID] = '" & [CarModel] & "-" & Left$([Category],1) & "'")+1,0)
Neither putting this code in control source or beforeupdate event of the form is not working.

I have looked around and from previous posts in the forum come up with this module. But it is not working either:
Public Function NewScreenID() As String

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim ScreenID As String
Dim CarModel As String
Dim Category As String

On Error GoTo Err_Execute

Set db = CurrentDb()


Set rst = CurrentDb.OpenRecordset("SELECT Max([Screenprep].[ScreenID]) AS MaxScreenID from [Screenprep];", dbOpenSnapshot)

If IsNull(rst!MaxScreenID) Then
NewScreenID = [CarModel] & "-" & Left$([Category], 1) & Format(1, "0000")
Else
NewScreenID = rst!MaxScreenID + 1
End If


rst.Close
Set rst = Nothing
Set db = Nothing

NewScreenID = ScreenID

Exit Function

Err_Execute:
'An error occurred, return blank string
NewScreenID = ""
MsgBox "An error occurred while trying to determine the next sequential number to assign."


End Function

In advance thank you for your time.Can someone please guide me on how to sort this out?

View 1 Replies View Related

Modules & VBA :: Sequential Numbering Dcount Dmax Composite Primary Key

Sep 23, 2014

I have a question concerning the automatically sequential numbering of a primary key as part of a composite primary key.

Tbl_treatment:
ID=numeric field (also in tbl_pt and in tbl_tumor)
Tumornr=numeric field (also in tbl_tumor)
Treatmentnr=numeric field

[ID] and [tumornr] are fixed and i would like to automatically number [treatmentnr] per [ID] AND [tumornr] in a way that the output will look like this:

1001 1 1
1001 1 2
1001 1 3
1001 2 1
1001 2 2
1001 3 1, etcetera.

However, when i use the SQL-formula below my output looks like this. It seems as if the function is not properly taking the composite primary key of [ID] AND [tumornr] into account or not finding the true max value:

1001 1 1
1001 1 2
1001 1 3
1001 2 2
1001 2 3
1001 3 3, etcetera.

If (DCount("[treatmentnr]", "Tbl_treatment", "[ID] = " & Me.ID & "" & "AND [tumornr] = " & Me.tumornr & "")) = 0 Then Me.treatmentnr = fRowNum(False)
Else Me.treatmentnr = (DMax("[treatmentnr]", "Tbl_treatment", "[ID] = " & Me.ID & "" & "AND [tumornr] = " & Me.tumornr & "")) + 1

View 3 Replies View Related

Forms :: DMax Criteria - Creating A Form To Input New Return Parts Into Database

May 22, 2013

I am currently creating a form to input new return parts into a database. I am trying to automatically generate a tracking number (##-AA-####-####). I have gotten myself to generate the ##-AA-#### in a list box and almost was able to generate the sequence number, 0001, 0002, etc. using the dmax function. I would like to generate the sequence number one higher than the highest, depending on part type and last 4 digits of part number. Our parts have unique last 4 different p/n but more than one can fall under the same type.

View 14 Replies View Related

Forms :: Custom Sequential Auto-number Of Different Series

Aug 18, 2015

I am using Ms Access 2007 and I am new to it..I have table of following fileds

ID (as a primary key)

AccountingYear (Filed for current accounting Year e.g., 14-15; 15-16)

Series (text- as R, Y, B etc to denote series code)

OrderNo (field to store custom autonumber Order No e.g., for Series R-1, R-2, for series Y Y-1, Y-2, etc)

I have created a form using all these fields..Now what i want to do is I want to create custom order no as first 2 digit of accounting year+Series+Autonumber of respective series as

14R-1
14R-2
14Y-1
14Y-2
14Y-3
14B-1

15R-1
15R-2
15Y-1
15Y-2

Means autonumber starts with 1 for every accounting year of respective Series..how to do this and what code or formula should be applied and where the code should be inserted as I am new to Ms access

View 1 Replies View Related

Forms :: How To Update Field Sequential Number In Subform

Jun 4, 2014

1. Which event occurs when anything changes on subform (Delete row , add row , perform the sort, Especially when you add a row to be inserted in the current sorting between the rows)

2. I have column sequential number that need updating when occurs any event on subform

3. "On current" is event that occurs always when changing rows in subform, how to process rows sequential (row by row) thru subform and update field that represent sequential number.

View 2 Replies View Related

Sequential Number

Jan 22, 2007

Hello, I am very new to access and I am trying to create a simple sytem to help us create part numbers. We are using a 2 digit descriptor to help define the part some. Then we want to add a sequential 7 digit number on to that.

Example:

01 (is electrical)
02 (Shop supplies)
etc....

So...

01-0000001 would be a part number for an electrical part.

I do not understand how to have access add the zeros to the front. I would also like to be able to jump a bit out of line to reserve part numbers for certain projects and also include some that we already have.

If this make any sense to anyone, any help would be appreciated!

Thanks,
james

View 3 Replies View Related

Sequential Number Generation

Sep 11, 2006

Hi guys, im new to all this so take it easy

Im trying to create a document register in Access 97 to create and track document numbers, for this i want to assign a 6 number unique id to each record starting at 000001 going up in order to 999999 which will form part of a unique docuement number ...i know this may be a really easy thing to do but can anyone tell me how?


Cheers

Dave

View 1 Replies View Related

Returning A Sequential Number

Mar 11, 2008

I have a form on which I need to print a sequential number - increasing by 1 each time the form is printed. I cannot think of a way to do that - perhaps something returned from a query? Any suggestions?

Robert

View 3 Replies View Related

Sequential Number Problem

Nov 10, 2006

I've tried using DMax codes shared by the generous members of this group. But i can't get the results i needed. :-(

My table consists of the following fields:

ColID - PK
PolID - FK
AmountPaid
ORDate
ORNo

I added another field which i named "ColNo" - this field should assign a sequential number to a new payment record for a specific PolID.

My table looks like this:

ColID PolID AmountPaid ORDate
11125 123 2,000 10-Sep-06
11126 123 2,000 10-Oct-06
11127 123 2,000 10-Nov-06
11128 456 1,000 8-Aug-06
11129 456 1,000 8-Sep-06
11130 789 4,000 21-Aug-06

Again, my idea is to create a sequential number for the ColNo field:

ColID PolID AmountPaid ORDate ColNo
11125 123 2,000 10-Sep-06 1
11126 123 2,000 10-Oct-06 2
11127 123 2,000 10-Nov-06 3
11128 456 1,000 8-Aug-06 1
11129 456 1,000 8-Sep-06 2
11130 789 4,000 21-Aug-06 1

I placed the code Nz{DMax("field name","table name"),0)+1 on the control source of the ColNo field and i also tried copying numerous similar codes to the BeforeInsert, OnCurrent, etc.. events, but the result is ALWAYS THE NEXT MAXIMUM NUMBERFOR THE "ENTIRE" POLID.

What i mean is, if i enter a new record, it would give me a sequential number of "4". I figured out this is because 3 is the last maximum number as i have shown on my sample table. Even if i use the PolID "789", the number shown on the ColNo field results to "4".

IT SHOULD HAVE BEEN "2". Considering that the last ColNo used for PolID 456 was "1".

Hope someone could help me on this..


Thanks!
Sheila

View 4 Replies View Related

Access Sequential Number

Apr 16, 2008

Hi, im pretty new to access, i need some help or a pointer on how to set up a sequential number. i have a orders table with an order number starting GO how to i get access to count up in ones from the starting number.
regards

View 14 Replies View Related

Sequential Order Number With Alphanumeric Value

Jan 25, 2007

Dear All,

I know that there may have been many posts on this and I have searched for a total of about 2 hours in these forums before posting, so please don't shoot me down for asking this.

I simply need to know how I can create a unique, alphanumeric order number. I was going to use Autonumber, but from what I have read on these forums, that is not the way to go, as Autonumber is simply to identify the record.

What I need is an number like so: ST000. It needs to start at ST142 and increase by one each time. Obviously I would like to avoid gaps from records being deleted or not completed etc.....

I really have no clue how to do this, and would appreciate it if anyone can point me to a post that would help, or offer me the solution.

Thanks,

View 13 Replies View Related

Sequential Number By Group In A Field?

Jul 19, 2015

I have a table like the one below. I need to Auto Sequence based on JobIDOne in the field that says sequence in the manner that I've typed. Hand typing is not an option because by table will be updated regularly. All other fields are updated via a form. I need a either a macro or VBA solution that can reconcile this, preferably through the table. Note, I do not want to use a query to create this sequencing or SQL language as I do not know how to write SQL commands.

I know it can be done but I've seen about a thousand ways to do it that I haven't been able to modify for my specific table.

DateOne
TimeIn
JobIDOne
InitialsOne
Dates Worked One
Sequence

7/17/2015
6:45:10 PM
12345
AR
7/17/2015
1

[code]....

View 14 Replies View Related

Generating Invoice Number

Jan 15, 2007

I have a small .mdb for invoicing. Till now I had to put invoice number, which had two parts, manually for the first part, for example 001 or 002 and automatically for the second part as Date part. So I had, for example 2006 or 2007. The complete number was, for example 001/2006 etc.

The problem was New Year. Now, all previous invoices from 2006 have 2007 extension and the first parts are not starting form 001 but they continue.

View 10 Replies View Related

Generating A Service Number Using VBA

Aug 18, 2005

Hi,
I'm trying to make a database where a Date and a Service Number is entered into a form.

I have 2 buttons, one to automatically enter the Current Date and the second to automatically enter the Service Number.

The service number is incrimented by 1 each time and reset for every day.

eg.

Date Service Number
January 1, 2005 1
January 1, 2005 2
January 1, 2005 3
January 2, 2005 1
January 2, 2005 2
January 5, 2005 1
January 5, 2005 2

I already have the button that enters the Current Date. However, I am having trouble with the second button.

How can I code the button so that it searches the table for the Current Date and finds the record with the greatest service number for that date? After this is done, I want to create code that will automatically enter the next service number into the Service Number Textbox on the form.

eg. Using the Example Table Above
The date January 5, 2005 is entered into the Date Text Box and the Search Next Service Number button is pressed. The number '3' should show up in the Service Number Textbox

Sorry if its hard to understand, but thanks anyways.

I just realized that I placed this in the wrong forum, Sorry for the inconvenience.

View 2 Replies View Related

Sequential Number Created By A Query URGENT

Jan 5, 2006

I am trying to create a sequential number field in a query. I cant use an auto number for the fact that i am combining multiple tables. Any help with this would be greatly appreciated.

View 14 Replies View Related

Queries :: Query To Add Sequential Number To Table

Dec 16, 2013

We have a large database table [PRODUCT] with the following fields PROPNUM and P_Date and GAS. We need to normalize the GAS field to the first month of production based on P_Date and sequential months following to average the data. We believe the easiest way is to create a sequential number for each Key PROPNUM that represents the first month of GAS the second month of GAS etc.

We have followed several of the posts on how to sequentially number records, but are struggling to get them to work.The latest effort was to use the make a table query creating an expression with the following.

DCount("*","PRODUCT","[PROPNUM]=" & [PROPNUM] & " AND[P_DATE]<=#" & Format([P_DATE],"mm/dd/yyyy") & "#")

View 2 Replies View Related

Sequential Number On The Basis Of Cell Value In Table

Feb 25, 2014

I have a table called External Audit.

I want each record to get a unique sequential number on the basis of Type of Audit.

Type of Audit column has 3 options OB, INR, MINR to choose from

If i select type as OB then the notification number should start from 1 and carry on numbering it whenever I select the same value.

When I select different type eg: INR then it should again start number on the basis of type. INR1 INR2, INR3 etc.

Is sequential number is the right word to use for this function ?

View 10 Replies View Related

Generating An Auto-number In A Report?

Feb 8, 2008

First off, can it be done? I'm using Microsoft Access 2007, I'm wanting to generate an auto-number on the report. Basically I have an OrderTable, a PartTable, and a PackingListTable. I have a report that shows all orders ready to be shipped. But I need the shipping report to have a packing list number. I want this number to be auto-generated, and I was hoping I could do this when the report is opened. Right now the report is generated through a query of orders that are ready to be shipped. Yet I can't figure out how to put an auto-generated packing number on the report.

View 1 Replies View Related

General :: Creating Auto-Sequential Order Number

May 6, 2013

I am trying to create an auto-sequential order number

Example : AB000112 - AB is standard prefix, ''0001'' is the first invoice number, ''12'' is the year 2012.

so the next order number should read AB000212 and the next AB000312

Out of this, I have to issue several debit notes relating to the same order number when the payments are due from customers over a period of time, this will be

001AB000112
002AB000112
003AB000112

Can such numbers be the primary key?

View 4 Replies View Related

Seeking Much Help With Generating A Card Number From Another Field

Jan 14, 2008

Hi guys,

I need some help here and any would be muchly apprieciated.

I am building a database for a theme park fast pass system where a customer can book themselves a place on a ride at three session times a day.

Now my problem is, that I need to generate a card number. 5555 1946 as the first 8 digits (this always stays the same) and then the last 8 digits is the customer ID number, which is in the same table. So there are 16 digits in total.

Let me give you an example:

A new customer registers and are assigned a customer ID of 1000 0001. Therefore the Card Number for that customer must be 5555 1946 1000 0001.

I have used auto number for customer ID so when a new customer signs up, there ID is 1 more that highest already in te database.

Simple question really...but how is this done?

A million marks for someone who breaks it! Hehe

Thanks

View 1 Replies View Related

Modules & VBA :: Adding Additional Sequential Number To Avoid Duplicate Value

Jun 10, 2013

I am not sure if it is possible to implement this but I would like your input. We get request from client via a web based form which contains a unique ID number called RDEFNumber. When we process the request internally, we use this number to identify the request throughout the process. The request from client contains processing of multiple files which are transmitted to us in different times of the day or days.

Every time we receive a file, an email is sent to the IT team with all the information about the file. We use an internal database to send the email to the IT team and use the RDEFNumber as the identifier in the subject line. What I am trying to do is to add an additional number at the end of the RDEFNumber automatically to differentiate the subject line.

For example, we take "1791" as a RDEFNumber. For the first time we enter 1791 to the database RDEFNumber field, it should check the table "tblRDEF" (record source) for duplicate value. If no Duplicate exists, it should keep the number as same. When we get the next file for processing with the same 1791 number and enter this number in the RDEFNumber field, it should automatically change it to "1791-1" since "1791" already exists in the database. When we get the next file, the number should change to "1791-2" and then "1791-3" and on.

View 13 Replies View Related

Queries :: How To Add Sequential Dates With Reference Number With Append Query

Apr 7, 2015

I want to populate a table with field:date and field ref nr.(7 fixed ProductID's)

But only weekday and to 3 years from now. (every weekday)

Example

field:ID | date | fixed.ref.nr
--------------------------------
1 | 7/4/2015 | 1001
2 | 8/4/2015 | 1002
3 | 9/4/2015 | 1003
4 | 10/4/2015 | 1004
5 | 13/4/2015 | 1005
6 | 14/4/2015 | 1006
7 | 15/4/2015 | 1007
8 | 16/4/2015 | 1001
9 | 17/4/2015 | 1002
10 | 18/4/2015 | 1003
.... (ID field is autonumber field and not important..)

How to do this with a append query or code?

View 1 Replies View Related

General :: Create A New Record / Also Generating A New Auto Number

Dec 3, 2014

When I create a new record I am also generating a new Auto Number. This is so I have a sure fire way of returning the records that I want to return. I have read where it is a known issue that when using the Compact and Repair it can reset the Auto Number to a lower number and generate a duplicate Auto Number. That is the problem that I have at this time. I have tried using the Allen code but it doesn't seem to worked on linked tables. I use linked tables because I have multiple users who can access this system at any given point in time.how to have the Auto Number field select a number that is unique

View 12 Replies View Related

Generating Scores Based On Number Of Tick Boxes?

May 3, 2012

I am wondering if it is possible to calculate scores automatically based on the number of tick boxes the users have selected? If yes, how do I go about doing this feature?

View 5 Replies View Related

Queries :: Adding Sequential Numbers To Generate A Unique Reference Number

Oct 5, 2013

Basically what I have is a database for tracking/logging parcels that arrive to the office. I want to be able to generate a reference number based on the date of arrival: i.e. the reference number should be ddmmyy### where ### is a sequential number. I know that I could just use the primary key's autonumber, for the sequential number but if I do this then the sequence will not restart at 1 on each date and because we receive a lot of parcels the reference number will grow to be too big to print out on the collection slips in just a few months.

two tables (one with the date and staff on duty that day and the other with the parcel's info') with a one to many relationship

I also have a query (Named: FullLog) that picks up the following data from the tables:

Name - Description - Size - TrackingInfo' - Staff - DateReceived - Count

The field named Count is a DCount function that I used to find out the number of times each date is repeated. This is the Expression that I used:

Count: DCount("*","FullLog","DateReceived = " & [DateReceived]) [Note that DateReceived is first converted into a string using CStr()]

This is as far as I have been able to get, I have been looking for weeks for a solution to this problem but I have yet to find one. I don't even know if the DCount function is the correct way of doing it, I did read somewhere that this produces a very slow query.

Effectively what I want to be able to get is something of that resembles the following

DateReceived - ReferenceNo

051013 051013001
051013 051013002
051013 051013003
061013 061013001
061013 061013002
071013 071013001
071013 071013002
071013 071013003
071013 071013004
071013 071013005
081013 081013001
081013 081013002
091013 091013001
101013 101013001

View 6 Replies View Related







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