PC Review


Reply
Thread Tools Rate Thread

Automatically Generating Next Number in a Series

 
 
=?Utf-8?B?U2FyZ2VudEFQ?=
Guest
Posts: n/a
 
      15th Aug 2006
I would like to have a function within my database where the next available
number in a series is automatically found and inserted. For example, I want
to generate a file number, but I can't use Auto Number since I will sometime
insert a batch of info and I think that would mess auto number up. I want
the function to look at 1, 3, 76, 982, and know that the next number it
should pick is 983. Help!!
--
Andrea Sargent
President
A Virtual Wonder LLC
www.avirtualwonder.com
 
Reply With Quote
 
 
 
 
Alessandro Baraldi
Guest
Posts: n/a
 
      15th Aug 2006

SargentAP ha scritto:

> I would like to have a function within my database where the next available
> number in a series is automatically found and inserted. For example, I want
> to generate a file number, but I can't use Auto Number since I will sometime
> insert a batch of info and I think that would mess auto number up. I want
> the function to look at 1, 3, 76, 982, and know that the next number it
> should pick is 983. Help!!
> --
> Andrea Sargent
> President
> A Virtual Wonder LLC
> www.avirtualwonder.com


May be like this...?

On DefaultValue property
=Nz(Dmax([Fieldname];"TableName"),0)+1

@Alex

 
Reply With Quote
 
Jerry Porter
Guest
Posts: n/a
 
      15th Aug 2006
AutoNumber should work fine if you insert a batch of records. I do it
all the time.

Jerry

 
Reply With Quote
 
=?Utf-8?B?ZGNhc2g0NQ==?=
Guest
Posts: n/a
 
      16th Aug 2006
Think I had the same problem you are having and someone help me out with that
problem.

Heres the code they show me...so Im pasting on to you....This is what I
believe you are looking for....

This code goes in the form that you are using...

'Assign the new member 1 membership ID before added to database.
Me![MembershipID] = NewMembershipID()


This code rite here...goes into a module and also you will have to change
something to see fix your needs...

'Got code from:
'Name: NewMembershipID
'Purpose: To find the last MembershipID then + 1 for the new member's ID
'Edit by:
'Create on: 7/6/2006

Public Function NewMembershipID() As Long

On Error GoTo NextID_Err

Dim NextMembershipID As Long

'Find highest Membership ID in the tblMembership table and add 1
NextMembershipID = DMax("[MembershipID]", "tblMembership2") + 1

'Assign function the value of the Next ID
NewMembershipID = NextMembershipID

'Exit function now after successful incrementing or after error message
Exit_NewMembershipID:
Exit Function

'If an error occurred, display a message, then go to Exit statement
NextID_Err:
MsgBox "Error " & Err & ": " & Error$

Resume Exit_NewMembershipID

End Function


I hope this help..........
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How: automatically re-adjust number series Josh W Microsoft Excel Misc 6 11th May 2008 06:53 PM
Automatically generating a series of reports =?Utf-8?B?Qm9iaw==?= Microsoft Access Form Coding 2 7th Aug 2007 06:30 AM
Generating time based series =?Utf-8?B?UGV0ZQ==?= Microsoft Excel Charting 1 19th Sep 2006 08:28 AM
Automatically generating a number range =?Utf-8?B?QWx5c3NhIEMu?= Microsoft Excel Worksheet Functions 2 5th Sep 2006 11:24 PM
Automatically generating a specified number of new rows (records) =?Utf-8?B?TGVsZQ==?= Microsoft Excel Programming 6 1st Apr 2006 11:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:15 PM.