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 Programming / January 2005

Tip: Looking for answers? Try searching our database.

Add 1 to Work Order #

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tvh - 25 Jan 2005 15:51 GMT
I have a command button in a form that creates a new Work Order.  I would
like it to add 1 to the highest number in the table, i.e., our Work Orders
are numbered W-100, W-101, etc.  I have tried placing the following code in
the BeforeUpdate event procedure, but nothing happens when I use the command
button.  Does the DMax() code have to be placed within the command button
code?  Also, does the "#" sign in my table/field names have an affect on the
codes?

If IsNull(Me![tblwoWorkOrder#]) Then
   Me![tblwoWorkOrder#] = Nz(DMax("[tblwoWorkOrder#]", "tblWorkOrder#"), 0)
+ 1
End If

Thanks!
anonymous@discussions.microsoft.com - 25 Jan 2005 16:37 GMT
hi,
W-101 is not a number. it's text and you cannot add 1 to
it. that goes against computer logic.
you will have to seperate the w- from the 101 to do what
you want

SELECT "W-" & Right(Max([tblwoWorkOrder#]),3)+1 AS WONum
FROM tblWorkOrder;

Not sure if i got your table and field names right.
you can pop the results of the query into your text box.

>-----Original Message-----
>I have a command button in a form that creates a new Work Order.  I would
[quoted text clipped - 12 lines]
>Thanks!
>.
tvh - 25 Jan 2005 17:05 GMT
Thank you for the reply, but where do I place this code so that when I click
the "Create New Work Order" button, the new sequential number is placed in
the field.

> hi,
> W-101 is not a number. it's text and you cannot add 1 to
[quoted text clipped - 31 lines]
> >Thanks!
> >.
 
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.