Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / December 2007

Tip: Looking for answers? Try searching our database.

Invoice Number

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pushrodengine - 15 Dec 2007 15:06 GMT
I need an Invoice Number text box in the format of "0000-yy" where the “0000”
increases +1 automatically.

Thanks
Ken Snell (MVP) - 15 Dec 2007 15:15 GMT
Do not store the "0000-yy" value in a single field. Instead, use two fields
(use Integer data type if numbers will not exceed 9999 in your example) --  
one for the "0000" part, and one for the "yy" part. Then concatenate the two
fields with a hyphen when you want to display the result:

SELECT Field0000 & "-" & Fieldyy AS InvoiceNumber,
FieldName1, FieldName2, FieldName3
FROM TableName;

Then you can use standard incrementing expressions to get the next value of
"0000" field for a given "yy" value:
       Nz(DMax("Field0000", "TableName", "Fieldyy= & DesiredYYvalue),0) + 1

Signature

       Ken Snell
<MS ACCESS MVP>

>I need an Invoice Number text box in the format of "0000-yy" where the
>"0000"
> increases +1 automatically.
>
> Thanks
pushrodengine - 16 Dec 2007 23:54 GMT
I'm using the code:

Default Value
="0000" & "-" & Right([Date],2)

Currently, the user must manually enter the correct value for “0000”.

Is there a way to modify this code to automatically increase “0000” +1?
Douglas J. Steele - 17 Dec 2007 00:21 GMT
Ken already gave you the code:

<quote>
Then you can use standard incrementing expressions to get the next value of
"0000" field for a given "yy" value:
       Nz(DMax("Field0000", "TableName", "Fieldyy=" & DesiredYYvalue),0) +
1
</quote>

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

> I'm using the code:
>
[quoted text clipped - 4 lines]
>
> Is there a way to modify this code to automatically increase "0000" +1?
pushrodengine - 17 Dec 2007 00:59 GMT
Is this the only method?
pushrodengine - 17 Dec 2007 01:24 GMT
I have a textbox on the form that displays the last invoice number used named
“LastInvoice” and it has a control source of:

=DMax("[InvoiceNumber]","tblLog")

The "InoviceNumber" is in the format "0000-yy"

Is there a way to code the Default Value of the textbox “InvoiceID” so that
it's the “LastInvoice” textbox value, but increases it’s “0000” value +1.

So now the Default Value of textbox “InvoiceID” is the “LastInvoice” textbox
value “0000” +1 & “-“ & Right([Date],2)

Thanks
Douglas J. Steele - 17 Dec 2007 11:16 GMT
You could use a recordset rather than DMax, but there's no need to do that.

The important thing, though, is that you follow Ken's advice and split your
existing field into two separate fields, and concatenate the fields into a
single value for display purposes in a query.

Have two separate pieces of information in a single field, such as you
currently have, is actually a violation of database normalization
principles. You've already seen one of the effects of doing that: it's
difficult to work with the data!

BTW, simply reposting your question again in the same thread is NOT going to
get you a different answer. If you need more information about the answer,
or realized that you didn't give us all the details originally, indicate
what's different the second time: don't just repost the same question!

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

> Is this the only method?
pushrodengine - 17 Dec 2007 18:14 GMT
I have over 1,000 records so far in the table in the format of "0000-yy".

How exactly do I split the field without losing data or re-entering data?
Douglas J. Steele - 17 Dec 2007 20:49 GMT
Add two new fields to the table.

Create an update query that updates those two new fields. Let's assume that
the new fields are named NewID and IDYear, and that the old field was named
OldID. Your SQL would be something like:

UPDATE MyTable
SET NewId = Left([OldID], InStr([OldID], "-") - 1),
IDYear = Mid([OldID], InStr([OldID], "-") + 1)

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

>I have over 1,000 records so far in the table in the format of "0000-yy".
>
> How exactly do I split the field without losing data or re-entering data?
pushrodengine - 19 Dec 2007 21:07 GMT
Where do I enter:

SELECT Field0000 & "-" & Fieldyy AS InvoiceNumber,
FieldName1, FieldName2, FieldName3
FROM TableName;

Thanks
Douglas J. Steele - 20 Dec 2007 01:38 GMT
That's the SQL of a query. You create the query the way you create any other
queries, and then use that query instead of the table.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

> Where do I enter:
>
[quoted text clipped - 3 lines]
>
> Thanks
pushrodengine - 20 Dec 2007 21:25 GMT
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.